From 749a0d0e5f9d0f06135994c396c79bd1f56352b8 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Tue, 16 Sep 2025 21:48:05 +0100 Subject: [PATCH] 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. --- src/line_gap.sml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/line_gap.sml b/src/line_gap.sml index 8b76a02..f02998c 100644 --- a/src/line_gap.sml +++ b/src/line_gap.sml @@ -30,7 +30,7 @@ sig val goToIdx: int * t -> t val goToLine: int * t -> t - val getLineNumberOfIdx: int * t -> int + val idxToLineNumber: int * t -> int (* for testing *) val verifyIndex: t -> unit @@ -3136,7 +3136,7 @@ struct buffer end - fun getLineNumberLeft (findIdx, curIdx, curLine, leftStrings, leftLines) = + fun idxToLineNumberLeft (findIdx, curIdx, curLine, leftStrings, leftLines) = case (leftStrings, leftLines) of (shd :: stl, lhd :: ltl) => let @@ -3158,12 +3158,12 @@ struct end else let val prevLine = curLine - Vector.length lhd - in getLineNumberLeft (findIdx, prevIdx, prevLine, stl, ltl) + in idxToLineNumberLeft (findIdx, prevIdx, prevLine, stl, ltl) end end | (_, _) => 0 - fun getLineNumberRight (findIdx, curIdx, curLine, rightStrings, rightLines) = + fun idxToLineNumberRight (findIdx, curIdx, curLine, rightStrings, rightLines) = case (rightStrings, rightLines) of (shd :: stl, lhd :: ltl) => let @@ -3183,12 +3183,12 @@ struct end else let val nextLine = curLine + Vector.length lhd - in getLineNumberRight (findIdx, nextIdx, nextLine, stl, ltl) + in idxToLineNumberRight (findIdx, nextIdx, nextLine, stl, ltl) end end | (_, _) => curLine - fun getLineNumberOfIdx (findIdx, buffer: t) = + fun idxToLineNumber (findIdx, buffer: t) = let val { idx = curIdx @@ -3201,9 +3201,10 @@ struct } = buffer in if findIdx < curIdx then - getLineNumberLeft (findIdx, curIdx, curLine, leftStrings, leftLines) + idxToLineNumberLeft (findIdx, curIdx, curLine, leftStrings, leftLines) else if findIdx > curIdx then - getLineNumberRight (findIdx, curIdx, curLine, rightStrings, rightLines) + idxToLineNumberRight + (findIdx, curIdx, curLine, rightStrings, rightLines) else curLine end