From e0517ca8cda03c2f9585e01f480b3d962d43b5e9 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Tue, 10 Feb 2026 08:57:32 +0000 Subject: [PATCH] add tests related to searchList for 'dG' and 'dgg' motions --- temp.txt | 3 +- test/normal-delete-tests.sml | 105 +++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+), 1 deletion(-) diff --git a/temp.txt b/temp.txt index 4ac281b..6686177 100644 --- a/temp.txt +++ b/temp.txt @@ -1 +1,2 @@ -hello oops +alpha world +test again diff --git a/test/normal-delete-tests.sml b/test/normal-delete-tests.sml index 04e7f1f..1adb1a9 100644 --- a/test/normal-delete-tests.sml +++ b/test/normal-delete-tests.sml @@ -4648,6 +4648,72 @@ struct (actualString = expectedString andalso cursorIdx = expectedCursorIdx) end) + , test "leaves preceding matches unchhanged" (fn _ => + let + (* arrange *) + val originalIdx = 12 + val originalString = "hello world\ntest again\n" + + val app = TestUtils.init originalString + val app = AppWith.idx (app, originalIdx) + + val app = TestUtils.updateMany (app, "/hello") + val app = AppUpdate.update (app, InputMsg.KEY_ENTER, Time.now ()) + + (* act *) + val newApp = TestUtils.updateMany (app, "dG") + + (* assert *) + val oldSearchList = #searchList app + val oldSearchList = PersistentVector.toList oldSearchList + val newSearchList = #searchList newApp + val newSearchList = PersistentVector.toList newSearchList + + val expectedOldSearchList = [{start = 0, finish = 4}] + val expectedNewSearchList = expectedOldSearchList + + val assertion = + oldSearchList = expectedOldSearchList + andalso newSearchList = expectedNewSearchList + in + Expect.isTrue assertion + end) + , test "deletes all matches on deleted line" (fn _ => + let + (* arrange *) + val originalIdx = 12 + val originalString = "alpha world\ntest again\n" + + val app = TestUtils.init originalString + val app = AppWith.idx (app, originalIdx) + + val app = TestUtils.updateMany (app, "/a") + val app = AppUpdate.update (app, InputMsg.KEY_ENTER, Time.now ()) + + (* act *) + val newApp = TestUtils.updateMany (app, "dG") + + (* assert *) + val oldSearchList = #searchList app + val oldSearchList = PersistentVector.toList oldSearchList + val newSearchList = #searchList newApp + val newSearchList = PersistentVector.toList newSearchList + + val expectedOldSearchList = + [ {start = 0, finish = 0} + , {start = 4, finish = 4} + , {start = 17, finish = 17} + , {start = 19, finish = 19} + ] + val expectedNewSearchList = + [{start = 0, finish = 0}, {start = 4, finish = 4}] + + val assertion = + oldSearchList = expectedOldSearchList + andalso newSearchList = expectedNewSearchList + in + Expect.isTrue assertion + end) ] val dggDelete = describe "delete motion 'dgg'" @@ -4759,6 +4825,45 @@ struct (actualString = expectedString andalso cursorIdx = expectedCursorIdx) end) + , test + "deletes all matches on deleted line, \ + \and decrements subsequent matches" + (fn _ => + let + (* arrange *) + val originalIdx = 0 + val originalString = "alpha world\ntest again\n" + + val app = TestUtils.init originalString + val app = AppWith.idx (app, originalIdx) + + val app = TestUtils.updateMany (app, "/a") + val app = AppUpdate.update (app, InputMsg.KEY_ENTER, Time.now ()) + + (* act *) + val newApp = TestUtils.updateMany (app, "dgg") + + (* assert *) + val oldSearchList = #searchList app + val oldSearchList = PersistentVector.toList oldSearchList + val newSearchList = #searchList newApp + val newSearchList = PersistentVector.toList newSearchList + + val expectedOldSearchList = + [ {start = 0, finish = 0} + , {start = 4, finish = 4} + , {start = 17, finish = 17} + , {start = 19, finish = 19} + ] + val expectedNewSearchList = + [{start = 5, finish = 5}, {start = 7, finish = 7}] + + val assertion = + oldSearchList = expectedOldSearchList + andalso newSearchList = expectedNewSearchList + in + Expect.isTrue assertion + end) ] val d0Delete = describe "delete motion 'd0'"