From bf55373f6dae94e8ae6b9055d44e4eda7b98c4f2 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Thu, 25 Sep 2025 10:49:20 +0100 Subject: [PATCH] fix 'MakeNormalDelete.deleteLineBack' test, which failed because we were using the wrong way to check if cursor is currently at the start of the line. We checked '(endOfLine = cursorIdx) which works in most cases to verify that the current position is a newline, but fails when the cursor is at the last non-newline character of the line. This is fixed by being more precise and calling 'Cursor.isCursorAtStartOfLine' to check directly if the cursor is currently at the end of the line. --- fcore/normal-mode/make-normal-delete.sml | 6 ++++-- temp.txt | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/fcore/normal-mode/make-normal-delete.sml b/fcore/normal-mode/make-normal-delete.sml index 848e612..12a1769 100644 --- a/fcore/normal-mode/make-normal-delete.sml +++ b/fcore/normal-mode/make-normal-delete.sml @@ -547,8 +547,9 @@ struct * then we only want to delete 1 character at this line, * which is the newline the cursor is at. * Otherwise, we want to delete 2 chars by default. *) + val buffer = LineGap.goToIdx (endOfLine, buffer) val endOfLine = - if endOfLine = cursorIdx then endOfLine + 1 else endOfLine + 2 + if Cursor.isCursorAtStartOfLine (buffer, endOfLine) then endOfLine + 1 else endOfLine + 2 in finishDeleteLineBack (app, buffer, 0, endOfLine, endOfLine, time) end @@ -560,8 +561,9 @@ struct * then we don't want to delete the newline * as we are already deleting the newline * at the start of this range *) + val buffer = LineGap.goToIdx (endOfLine, buffer) val endOfLine = - if endOfLine = cursorIdx then endOfLine else endOfLine + 1 + if Cursor.isCursorAtStartOfLine (buffer, endOfLine) then endOfLine else endOfLine + 1 val buffer = LineGap.goToLine (newCursorLineNumber, buffer) diff --git a/temp.txt b/temp.txt index 204e3fd..7bd861d 100644 --- a/temp.txt +++ b/temp.txt @@ -1,5 +1,4 @@ hello world - trello brillo