add another test for 'df<char>' motion, checking that we leave a newline behind if the whole buffer is deleted
This commit is contained in:
@@ -728,6 +728,9 @@ struct
|
||||
val initialMsg = Fn.initMsgs (cursorIdx, length, buffer)
|
||||
val buffer = LineGap.delete (cursorIdx, length, buffer)
|
||||
|
||||
val buffer =
|
||||
if #textLength buffer = 0 then LineGap.fromString "\n" else buffer
|
||||
|
||||
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||
val cursorIdx =
|
||||
if Cursor.isOnNewlineAfterChr (buffer, cursorIdx) then cursorIdx - 1
|
||||
|
||||
@@ -3598,6 +3598,24 @@ struct
|
||||
(actualString = expectedString
|
||||
andalso cursorIdx = expectedCursorIdx)
|
||||
end)
|
||||
, test "leaves a newline behind if whole buffer is deleted" (fn _ =>
|
||||
let
|
||||
(* arrange *)
|
||||
val originalString = "hey hello\n"
|
||||
val app = TestUtils.init originalString
|
||||
val app = AppWith.idx (app, 0)
|
||||
|
||||
(* act *)
|
||||
val {buffer, cursorIdx, ...} = TestUtils.updateMany (app, "dfo")
|
||||
|
||||
(* assert *)
|
||||
val actualString = LineGap.toString buffer
|
||||
val expectedString = "\n"
|
||||
val expectedCursorIdx = 0
|
||||
in
|
||||
Expect.isTrue
|
||||
(actualString = expectedString andalso cursorIdx = expectedCursorIdx)
|
||||
end)
|
||||
]
|
||||
|
||||
val dtDelete = describe "delete motion 'dt<char>'"
|
||||
|
||||
Reference in New Issue
Block a user