add just one more 'word' test, extract steps to delete from search list into a reusable function (don't need to memorise the steps), and fix bug in cursor.sml where we were looking at tl without calculating correct strIdx
This commit is contained in:
@@ -363,6 +363,16 @@ struct
|
|||||||
|
|
||||||
(* text-delete functions *)
|
(* text-delete functions *)
|
||||||
(** equivalent of vi's 'x' command **)
|
(** equivalent of vi's 'x' command **)
|
||||||
|
|
||||||
|
fun deleteSearchList (cursorIdx, length, searchString, searchList, buffer) =
|
||||||
|
let
|
||||||
|
val searchList = SearchList.delete (cursorIdx, length, searchString, searchList)
|
||||||
|
val searchList = SearchList.mapFrom (cursorIdx, ~length, searchList)
|
||||||
|
in
|
||||||
|
BuildSearchList.fromRange
|
||||||
|
(cursorIdx, length, buffer, searchString, searchList)
|
||||||
|
end
|
||||||
|
|
||||||
fun helpRemoveChr (app: app_type, buffer, searchList, cursorIdx, count) =
|
fun helpRemoveChr (app: app_type, buffer, searchList, cursorIdx, count) =
|
||||||
if count = 0 then
|
if count = 0 then
|
||||||
let
|
let
|
||||||
@@ -423,11 +433,8 @@ struct
|
|||||||
val {searchString, ...} = app
|
val {searchString, ...} = app
|
||||||
val buffer = LineGap.delete (cursorIdx, 1, buffer)
|
val buffer = LineGap.delete (cursorIdx, 1, buffer)
|
||||||
|
|
||||||
val searchList = SearchList.delete (cursorIdx, 1, searchString, searchList)
|
|
||||||
val searchList = SearchList.mapFrom (cursorIdx, ~1, searchList)
|
|
||||||
val (buffer, searchList) =
|
val (buffer, searchList) =
|
||||||
BuildSearchList.fromRange
|
deleteSearchList (cursorIdx, 1, searchString, searchList, buffer)
|
||||||
(cursorIdx, 1, buffer, searchString, searchList)
|
|
||||||
|
|
||||||
val cursorIdx =
|
val cursorIdx =
|
||||||
if
|
if
|
||||||
@@ -443,11 +450,8 @@ struct
|
|||||||
val {searchString, ...} = app
|
val {searchString, ...} = app
|
||||||
val buffer = LineGap.delete (cursorIdx, 1, buffer)
|
val buffer = LineGap.delete (cursorIdx, 1, buffer)
|
||||||
|
|
||||||
val searchList = SearchList.delete (cursorIdx, 1, searchString, searchList)
|
|
||||||
val searchList = SearchList.mapFrom (cursorIdx, ~1, searchList)
|
|
||||||
val (buffer, searchList) =
|
val (buffer, searchList) =
|
||||||
BuildSearchList.fromRange
|
deleteSearchList (cursorIdx, 1, searchString, searchList, buffer)
|
||||||
(cursorIdx, 1, buffer, searchString, searchList)
|
|
||||||
in
|
in
|
||||||
helpRemoveChr (app, buffer, searchList, cursorIdx, count - 1)
|
helpRemoveChr (app, buffer, searchList, cursorIdx, count - 1)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1732,7 +1732,8 @@ struct
|
|||||||
(* strIdx is in tl *)
|
(* strIdx is in tl *)
|
||||||
(case tl of
|
(case tl of
|
||||||
tlhd :: tltl =>
|
tlhd :: tltl =>
|
||||||
helpIsNextChrEndOfLine (strIdx, tlhd, tltl)
|
helpIsNextChrEndOfLine
|
||||||
|
(strIdx - String.size hd, tlhd, tltl)
|
||||||
| [] =>
|
| [] =>
|
||||||
(* strIdx is at end of lineGap
|
(* strIdx is at end of lineGap
|
||||||
* which also means at end of line *)
|
* which also means at end of line *)
|
||||||
|
|||||||
@@ -730,6 +730,22 @@ val wMove = describe "move motion 'w'"
|
|||||||
in
|
in
|
||||||
Expect.isTrue (cursorChr = #"7")
|
Expect.isTrue (cursorChr = #"7")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
, test "moves cursor to first alphanumeric char when in punctuation" (fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val buffer = LineGap.fromString "!!! hello\n"
|
||||||
|
val app = AppType.init (buffer, 0, 0)
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val (app1, _) = AppUpdate.update (app, CHAR_EVENT #"w")
|
||||||
|
|
||||||
|
(* assert *)
|
||||||
|
val startsAtExc = getChr app = #"!"
|
||||||
|
val movedToH = getChr app1 = #"h"
|
||||||
|
in
|
||||||
|
Expect.isTrue (startsAtExc andalso movedToH)
|
||||||
|
end)
|
||||||
]
|
]
|
||||||
|
|
||||||
val tests = concat [hMove, lMove, jMove, kMove, wMove]
|
val tests = concat [hMove, lMove, jMove, kMove, wMove]
|
||||||
|
|||||||
Reference in New Issue
Block a user