From 7a8961af9c58e44c81ecc84de4b5e9bb77bfc976 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Wed, 3 Dec 2025 00:31:57 +0000 Subject: [PATCH] special case LineGap.goToLine, when the line requested to go to is 0. When this happens, we call 'LineGap.goToStart'. --- src/line_gap.sml | 61 +++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/src/line_gap.sml b/src/line_gap.sml index 67fe59d..a38ceaa 100644 --- a/src/line_gap.sml +++ b/src/line_gap.sml @@ -3047,36 +3047,39 @@ struct , lineLength } = buffer in - (* we compare current line with searchLine - 1 - * because if searchLine - 1 is here, - * that means we can access the linebreak - * that starts searchLine *) - if searchLine - 1 < line then - helpGoToLineLeft - ( idx - , line - , searchLine - , leftStrings - , leftLines - , rightStrings - , rightLines - , textLength - , lineLength - ) - else if searchLine - 1 > line then - helpGoToLineRight - ( idx - , line - , searchLine - , leftStrings - , leftLines - , rightStrings - , rightLines - , textLength - , lineLength - ) + if searchLine <= 0 then + LineGap.goToStart buffer else - buffer + (* we compare current line with searchLine - 1 + * because if searchLine - 1 is here, + * that means we can access the linebreak + * that starts searchLine *) + (if searchLine - 1 < line then + helpGoToLineLeft + ( idx + , line + , searchLine + , leftStrings + , leftLines + , rightStrings + , rightLines + , textLength + , lineLength + ) + else if searchLine - 1 > line then + helpGoToLineRight + ( idx + , line + , searchLine + , leftStrings + , leftLines + , rightStrings + , rightLines + , textLength + , lineLength + ) + else + buffer) end fun helpGoToIdxLeft