From a037211763b430c065337e65ead58ac5dcd8b434 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Sun, 7 Sep 2025 21:09:20 +0100 Subject: [PATCH] add a new test validating that the cursor does not move when cursor is on an empty line --- fcore/normal-mode/normal-yank.sml | 1 - shf-tests.mlb | 4 +++- test/normal-move.sml | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/fcore/normal-mode/normal-yank.sml b/fcore/normal-mode/normal-yank.sml index 268a0bb..cb5e371 100644 --- a/fcore/normal-mode/normal-yank.sml +++ b/fcore/normal-mode/normal-yank.sml @@ -102,7 +102,6 @@ struct if cursorIdx > otherIdx then (* yanking backwards from cursorIdx *) let - val () = print "272\n" val length = cursorIdx - otherIdx + 1 val buffer = LineGap.goToIdx (otherIdx, buffer) diff --git a/shf-tests.mlb b/shf-tests.mlb index 270b73a..6a619bf 100644 --- a/shf-tests.mlb +++ b/shf-tests.mlb @@ -45,13 +45,15 @@ fcore/normal-mode/normal-search-finish.sml fcore/move.sml fcore/normal-mode/normal-move.sml +fcore/normal-mode/normal-yank.sml +fcore/normal-mode/make-normal-delete.sml fcore/normal-mode/normal-delete.sml +fcore/normal-mode/normal-yank-delete.sml fcore/normal-mode/normal-mode.sml fcore/normal-mode/normal-search-mode.sml fcore/app-update.sml - (* TEST FILES *) $(SML_LIB)/basis/mlton.mlb shell/exception-logger.sml diff --git a/test/normal-move.sml b/test/normal-move.sml index 1a8a320..1535126 100644 --- a/test/normal-move.sml +++ b/test/normal-move.sml @@ -1482,6 +1482,24 @@ struct (* assert *) Expect.isTrue (oldIdx = newIdx) end) + , test "does not move cursor when cursor is on a newline" (fn _ => + let + (* arrange *) + val buffer = LineGap.fromString "hello\n\nworld\n" + val app = TestUtils.init buffer + val app = AppWith.idx (app, 6) + val oldIdx = #cursorIdx app + + (* act *) + val app = TestUtils.update (app, CHAR_EVENT #"$") + val newIdx = #cursorIdx app + + val nchr = getChr app + val nchr = Char.toString nchr ^ "\n" + in + (* assert *) + Expect.isTrue (oldIdx = newIdx) + end) ] val hatMove = describe "move motion '^'"