fix bugs in helper functions for 'LineGap.getLineNumberOfIdx'. Main bug was that we were passing 'curLine' to 'getLineNumberRight' twice, instead of first passing 'curIdx' and then 'curLine' afterwards.
This commit is contained in:
@@ -2663,10 +2663,10 @@ struct
|
|||||||
else
|
else
|
||||||
let
|
let
|
||||||
val prevLine = curLine - Vector.length lhd
|
val prevLine = curLine - Vector.length lhd
|
||||||
val relativeIdx = findIdx - prevIdx
|
val relativeIdx = findIdx - prevIdx - 1
|
||||||
val relativeLine = binSearch (relativeIdx, lhd)
|
val relativeLine = binSearch (relativeIdx, lhd) + 1
|
||||||
in
|
in
|
||||||
if relativeLine < 0 then prevLine else prevLine + relativeLine
|
prevLine + relativeLine
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
let val prevLine = curLine - Vector.length lhd
|
let val prevLine = curLine - Vector.length lhd
|
||||||
@@ -2688,10 +2688,10 @@ struct
|
|||||||
curLine
|
curLine
|
||||||
else
|
else
|
||||||
let
|
let
|
||||||
val relativeIdx = findIdx - curIdx
|
val relativeIdx = findIdx - curIdx - 1
|
||||||
val relativeLine = binSearch (relativeIdx, lhd)
|
val relativeLine = binSearch (relativeIdx, lhd) + 1
|
||||||
in
|
in
|
||||||
if relativeLine < 0 then curLine else curLine + relativeLine
|
curLine + relativeLine
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
let val nextLine = curLine + Vector.length lhd
|
let val nextLine = curLine + Vector.length lhd
|
||||||
@@ -2713,8 +2713,10 @@ struct
|
|||||||
in
|
in
|
||||||
if findIdx < curIdx then
|
if findIdx < curIdx then
|
||||||
getLineNumberLeft (findIdx, curIdx, curLine, leftStrings, leftLines)
|
getLineNumberLeft (findIdx, curIdx, curLine, leftStrings, leftLines)
|
||||||
|
else if findIdx > curIdx then
|
||||||
|
getLineNumberRight (findIdx, curIdx, curLine, rightStrings, rightLines)
|
||||||
else
|
else
|
||||||
getLineNumberRight (findIdx, curLine, curLine, rightStrings, rightLines)
|
curLine
|
||||||
end
|
end
|
||||||
|
|
||||||
(* TEST CODE *)
|
(* TEST CODE *)
|
||||||
|
|||||||
Reference in New Issue
Block a user