better naming for a function in line_gap.sml, making it clear that it takes an index and returns the line number that this index is at.
This commit is contained in:
@@ -30,7 +30,7 @@ sig
|
|||||||
val goToIdx: int * t -> t
|
val goToIdx: int * t -> t
|
||||||
val goToLine: int * t -> t
|
val goToLine: int * t -> t
|
||||||
|
|
||||||
val getLineNumberOfIdx: int * t -> int
|
val idxToLineNumber: int * t -> int
|
||||||
|
|
||||||
(* for testing *)
|
(* for testing *)
|
||||||
val verifyIndex: t -> unit
|
val verifyIndex: t -> unit
|
||||||
@@ -3136,7 +3136,7 @@ struct
|
|||||||
buffer
|
buffer
|
||||||
end
|
end
|
||||||
|
|
||||||
fun getLineNumberLeft (findIdx, curIdx, curLine, leftStrings, leftLines) =
|
fun idxToLineNumberLeft (findIdx, curIdx, curLine, leftStrings, leftLines) =
|
||||||
case (leftStrings, leftLines) of
|
case (leftStrings, leftLines) of
|
||||||
(shd :: stl, lhd :: ltl) =>
|
(shd :: stl, lhd :: ltl) =>
|
||||||
let
|
let
|
||||||
@@ -3158,12 +3158,12 @@ struct
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
let val prevLine = curLine - Vector.length lhd
|
let val prevLine = curLine - Vector.length lhd
|
||||||
in getLineNumberLeft (findIdx, prevIdx, prevLine, stl, ltl)
|
in idxToLineNumberLeft (findIdx, prevIdx, prevLine, stl, ltl)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
| (_, _) => 0
|
| (_, _) => 0
|
||||||
|
|
||||||
fun getLineNumberRight (findIdx, curIdx, curLine, rightStrings, rightLines) =
|
fun idxToLineNumberRight (findIdx, curIdx, curLine, rightStrings, rightLines) =
|
||||||
case (rightStrings, rightLines) of
|
case (rightStrings, rightLines) of
|
||||||
(shd :: stl, lhd :: ltl) =>
|
(shd :: stl, lhd :: ltl) =>
|
||||||
let
|
let
|
||||||
@@ -3183,12 +3183,12 @@ struct
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
let val nextLine = curLine + Vector.length lhd
|
let val nextLine = curLine + Vector.length lhd
|
||||||
in getLineNumberRight (findIdx, nextIdx, nextLine, stl, ltl)
|
in idxToLineNumberRight (findIdx, nextIdx, nextLine, stl, ltl)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
| (_, _) => curLine
|
| (_, _) => curLine
|
||||||
|
|
||||||
fun getLineNumberOfIdx (findIdx, buffer: t) =
|
fun idxToLineNumber (findIdx, buffer: t) =
|
||||||
let
|
let
|
||||||
val
|
val
|
||||||
{ idx = curIdx
|
{ idx = curIdx
|
||||||
@@ -3201,9 +3201,10 @@ struct
|
|||||||
} = buffer
|
} = buffer
|
||||||
in
|
in
|
||||||
if findIdx < curIdx then
|
if findIdx < curIdx then
|
||||||
getLineNumberLeft (findIdx, curIdx, curLine, leftStrings, leftLines)
|
idxToLineNumberLeft (findIdx, curIdx, curLine, leftStrings, leftLines)
|
||||||
else if findIdx > curIdx then
|
else if findIdx > curIdx then
|
||||||
getLineNumberRight (findIdx, curIdx, curLine, rightStrings, rightLines)
|
idxToLineNumberRight
|
||||||
|
(findIdx, curIdx, curLine, rightStrings, rightLines)
|
||||||
else
|
else
|
||||||
curLine
|
curLine
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user