reimplement 'dt' motion
This commit is contained in:
@@ -740,6 +740,21 @@ struct
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fun deleteTillNextChr (app: app_type, count, chr, time) =
|
||||||
|
let
|
||||||
|
val {buffer, cursorIdx, ...} = app
|
||||||
|
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||||
|
val newCursorIdx =
|
||||||
|
Cursor.toNextChrNew (buffer, cursorIdx, {findChr = chr, count = count})
|
||||||
|
in
|
||||||
|
if newCursorIdx = ~1 then
|
||||||
|
NormalFinish.clearMode app
|
||||||
|
else
|
||||||
|
let val length = newCursorIdx - cursorIdx
|
||||||
|
in deleteAndFinish (app, cursorIdx, length, buffer, time)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
fun deleteToStart (app: app_type, time) : AppType.app_type =
|
fun deleteToStart (app: app_type, time) : AppType.app_type =
|
||||||
let
|
let
|
||||||
val {cursorIdx, buffer, windowWidth, windowHeight, dfa, ...} = app
|
val {cursorIdx, buffer, windowWidth, windowHeight, dfa, ...} = app
|
||||||
|
|||||||
@@ -298,9 +298,7 @@ struct
|
|||||||
else
|
else
|
||||||
(* have to continue parsing string *)
|
(* have to continue parsing string *)
|
||||||
case String.sub (str, strPos + 1) of
|
case String.sub (str, strPos + 1) of
|
||||||
#"t" =>
|
#"t" => NormalDelete.deleteTillNextChr (app, count, chrCmd, time)
|
||||||
NormalDelete.deleteToChr
|
|
||||||
(app, 1, Cursor.tillNextChr, op+, chrCmd, time)
|
|
||||||
| #"T" =>
|
| #"T" =>
|
||||||
NormalDelete.deleteToChr
|
NormalDelete.deleteToChr
|
||||||
(app, 1, Cursor.tillPrevChr, op-, chrCmd, time)
|
(app, 1, Cursor.tillPrevChr, op-, chrCmd, time)
|
||||||
|
|||||||
@@ -3707,7 +3707,7 @@ struct
|
|||||||
andalso cursorIdx = expectedCursorIdx)
|
andalso cursorIdx = expectedCursorIdx)
|
||||||
end)
|
end)
|
||||||
, test
|
, test
|
||||||
"deletes up to just one occurrence \
|
"deletes up to (excluding) last occurrence of chr \
|
||||||
\when motion has a count greater than 1"
|
\when motion has a count greater than 1"
|
||||||
(fn _ =>
|
(fn _ =>
|
||||||
let
|
let
|
||||||
@@ -3721,7 +3721,7 @@ struct
|
|||||||
|
|
||||||
(* assert *)
|
(* assert *)
|
||||||
val actualString = LineGap.toString buffer
|
val actualString = LineGap.toString buffer
|
||||||
val expectedString = "o world\n"
|
val expectedString = "orld\n"
|
||||||
val expectedCursorIdx = 0
|
val expectedCursorIdx = 0
|
||||||
in
|
in
|
||||||
Expect.isTrue
|
Expect.isTrue
|
||||||
|
|||||||
Reference in New Issue
Block a user