From e70aab8952948ecefb5cd9482a6196953044b8e4 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Wed, 24 Sep 2025 09:07:26 +0100 Subject: [PATCH] add another failing test for 'dl' motion --- test/normal-delete.sml | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/test/normal-delete.sml b/test/normal-delete.sml index 7233f4a..55a1f06 100644 --- a/test/normal-delete.sml +++ b/test/normal-delete.sml @@ -215,7 +215,8 @@ struct end) , test "moves cursor to last newline after deleting \ - \all non-newline chars on last line" + \all non-newline chars on last line \ + \and the original string ends with a newline" (fn _ => let (* arrange *) @@ -238,6 +239,32 @@ struct in Expect.isTrue (stringIsExpected andalso cursorIdxIsExpected) end) + , test + "moves cursor to last newline after deleting \ + \all non-newline chars on last line \ + \and the original string does not end with a newline" + (fn _ => + let + (* arrange *) + val originalIdx = 6 + val originalString = "hello\nworld" + + val app = TestUtils.init originalString + val app = AppWith.idx (app, originalIdx) + + (* act *) + val {cursorIdx, buffer, ...} = TestUtils.updateMany (app, "33dl") + + (* assert *) + val actualString = LineGap.toString buffer + val expectedString = "hello\n" + val stringIsExpected = actualString = expectedString + + val expectedCursorIdx = 4 + val cursorIdxIsExpected = cursorIdx = expectedCursorIdx + in + Expect.isTrue (stringIsExpected andalso cursorIdxIsExpected) + end) ] val djDelete = describe "delete motion 'dj'"