done testing 'j' motion; next is to test 'k' motion
This commit is contained in:
@@ -182,7 +182,7 @@ val lMove = describe "move motion 'l'"
|
|||||||
Expect.isTrue (oldCursorIdx = 0 andalso cursorIdx = 1)
|
Expect.isTrue (oldCursorIdx = 0 andalso cursorIdx = 1)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
, test "does not move cursor right by one when cursorIdx = length" (fn _ =>
|
, test "does not move cursor when cursorIdx = length" (fn _ =>
|
||||||
let
|
let
|
||||||
(* arrange *)
|
(* arrange *)
|
||||||
val buffer = LineGap.fromString "hello world\n"
|
val buffer = LineGap.fromString "hello world\n"
|
||||||
@@ -388,6 +388,28 @@ val jMove = describe "move motion 'j'"
|
|||||||
in
|
in
|
||||||
Expect.isTrue isAtEnd
|
Expect.isTrue isAtEnd
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
, test "leaves cursor at same idx when already at end of buffer" (fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val str = "hello \nworld \ntime to go\n"
|
||||||
|
val len = String.size str - 2
|
||||||
|
val buffer = LineGap.fromString str
|
||||||
|
val app = AppType.init (buffer, 0, 0)
|
||||||
|
val app = withIdx (app, len)
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val ({cursorIdx, ...}, _) = AppUpdate.update (app, CHAR_EVENT #"j")
|
||||||
|
|
||||||
|
(* assert *)
|
||||||
|
(* String.size str - 1 is a valid char position
|
||||||
|
* but we are counting String.size str - 2 as the end
|
||||||
|
* because, in Vim, saved files always end with \n
|
||||||
|
* but the last char, \n, is not visible *)
|
||||||
|
val isAtEnd = cursorIdx = len
|
||||||
|
in
|
||||||
|
Expect.isTrue isAtEnd
|
||||||
|
end)
|
||||||
]
|
]
|
||||||
|
|
||||||
val wMove = describe "move motion 'w'"
|
val wMove = describe "move motion 'w'"
|
||||||
|
|||||||
Reference in New Issue
Block a user