add failing test for 'dj' motion, and progress reimplementing 'MakeNormalDelete.deleteLine'
This commit is contained in:
@@ -361,14 +361,17 @@ struct
|
|||||||
else endLineIdx
|
else endLineIdx
|
||||||
val buffer = LineGap.goToIdx (endLineIdx, buffer)
|
val buffer = LineGap.goToIdx (endLineIdx, buffer)
|
||||||
in
|
in
|
||||||
if Cursor.isOnNewlineAfterChr (buffer, endLineIdx) then
|
if Cursor.isCursorAtStartOfLine (buffer, endLineIdx) then
|
||||||
let
|
let
|
||||||
val endLineIdx = endLineIdx + 1
|
val endLineIdx =
|
||||||
|
if endLineIdx = #textLength buffer - 1 then endLineIdx - 1
|
||||||
|
else endLineIdx + 1
|
||||||
|
|
||||||
val length = endLineIdx - startIdx
|
val length = endLineIdx - startIdx
|
||||||
val initialMsg = Fn.initMsgs (startIdx, length, buffer)
|
val initialMsg = Fn.initMsgs (startIdx, length, buffer)
|
||||||
val buffer = LineGap.delete (startIdx, length, buffer)
|
val buffer = LineGap.delete (startIdx, length, buffer)
|
||||||
|
|
||||||
|
(* just need to reposition the cursor *)
|
||||||
val ss = LineGap.toString buffer
|
val ss = LineGap.toString buffer
|
||||||
val ss = String.toCString ss ^ "\n"
|
val ss = String.toCString ss ^ "\n"
|
||||||
val () = print ss
|
val () = print ss
|
||||||
|
|||||||
@@ -436,6 +436,28 @@ struct
|
|||||||
in
|
in
|
||||||
Expect.isTrue (stringIsExpected andalso cursorIdxIsExpected)
|
Expect.isTrue (stringIsExpected andalso cursorIdxIsExpected)
|
||||||
end)
|
end)
|
||||||
|
, test "deletes two lines when cursor is on a newline" (fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val originalString = "\nhello\nworld\ntrello\brillo\n"
|
||||||
|
val originalIdx = 0
|
||||||
|
|
||||||
|
val app = TestUtils.init originalString
|
||||||
|
val app = AppWith.idx (app, originalIdx)
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val {cursorIdx, buffer, ...} = TestUtils.updateMany (app, "dj")
|
||||||
|
|
||||||
|
(* assert *)
|
||||||
|
val expectedString = "world\ntrello\nbrillo\n"
|
||||||
|
val actualString = LineGap.toString buffer
|
||||||
|
val stringIsExpected = expectedString = actualString
|
||||||
|
|
||||||
|
val expectedCursorIdx = 0
|
||||||
|
val cursorIdxIsExpected = expectedCursorIdx = cursorIdx
|
||||||
|
in
|
||||||
|
Expect.isTrue (stringIsExpected andalso cursorIdxIsExpected)
|
||||||
|
end)
|
||||||
]
|
]
|
||||||
|
|
||||||
val tests = [dhDelete, dlDelete, djDelete]
|
val tests = [dhDelete, dlDelete, djDelete]
|
||||||
|
|||||||
Reference in New Issue
Block a user