From 5c7ec252c2cc16ad9f8cfeea5b1c6041ae670444 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Sat, 13 Sep 2025 03:51:33 +0100 Subject: [PATCH] don't index into line vector when getting line number from index; instead, just get how many previous-lines there are in the vector (if any) and add it to the line number of the current node. We do this because we are trying to get the line number of a particular index; accessing the line vector's contents (which are string indices) is not necessary nor helpful for that, but getting the relative line number is helpful for that --- src/line_gap.sml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/line_gap.sml b/src/line_gap.sml index caa9963..c1054a5 100644 --- a/src/line_gap.sml +++ b/src/line_gap.sml @@ -2666,8 +2666,7 @@ struct val relativeIdx = findIdx - prevIdx val relativeLine = binSearch (relativeIdx, lhd) in - if relativeLine < 0 then prevLine - else Vector.sub (lhd, relativeLine) + prevLine + if relativeLine < 0 then prevLine else prevLine + relativeLine end else let val prevLine = curLine - Vector.length lhd @@ -2691,10 +2690,8 @@ struct let val relativeIdx = findIdx - curIdx val relativeLine = binSearch (relativeIdx, lhd) - val lineOffset = - if relativeLine < 0 then 0 else Vector.sub (lhd, relativeLine) in - curLine + lineOffset + if relativeLine < 0 then curLine else curLine + relativeLine end else let val nextLine = curLine + Vector.length lhd