From 4925bcd370344280a86feee6e7db19b153f49d86 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Tue, 2 Dec 2025 23:49:29 +0000 Subject: [PATCH] for LineGap.lineNumberToIdx function, add a branch at the start checking if we are trying to get the idx corresponding to line number 0. This is needed by the current implementation because the 'lineNumberToIdxLeft' function uses (findLine - 1) in the implementation, and (0 - 1) is an invalid line idx as it is below 0. --- src/line_gap.sml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/line_gap.sml b/src/line_gap.sml index a464daf..67fe59d 100644 --- a/src/line_gap.sml +++ b/src/line_gap.sml @@ -3341,7 +3341,9 @@ struct , ... } = buffer in - if findLine - 1 < curLine then + if findLine = 0 then + 0 + else if findLine - 1 < curLine then lineNumberToIdxLeft (findLine, curIdx, curLine, leftStrings, leftLines) else lineNumberToIdxRight