add separate folder when deleting end of current word, so that we can fix 'de' and 'dE' motions (the result of the folders for the cursor motion is meant to be decremented by 1, but the result for deleting is not meant to be decremented or incremented at all)
This commit is contained in:
@@ -805,8 +805,8 @@ struct
|
|||||||
| #"W" => deleteByDfa (app, count, Cursor.nextWORD)
|
| #"W" => deleteByDfa (app, count, Cursor.nextWORD)
|
||||||
| #"b" => deleteByDfa (app, count, Cursor.prevWord)
|
| #"b" => deleteByDfa (app, count, Cursor.prevWord)
|
||||||
| #"B" => deleteByDfa (app, count, Cursor.prevWORD)
|
| #"B" => deleteByDfa (app, count, Cursor.prevWORD)
|
||||||
| #"e" => deleteByDfa (app, count, Cursor.endOfWord)
|
| #"e" => deleteByDfa (app, count, Cursor.endOfWordForDelete)
|
||||||
| #"E" => deleteByDfa (app, count, Cursor.endOfWORD)
|
| #"E" => deleteByDfa (app, count, Cursor.endOfWORDForDelete)
|
||||||
| #"0" => delete (app, 1, Cursor.vi0)
|
| #"0" => delete (app, 1, Cursor.vi0)
|
||||||
| #"$" => deleteToEndOfLine app
|
| #"$" => deleteToEndOfLine app
|
||||||
| #"^" => deleteToFirstNonSpaceChr app
|
| #"^" => deleteToFirstNonSpaceChr app
|
||||||
|
|||||||
@@ -123,6 +123,25 @@ struct
|
|||||||
val fStart = EndOfCurrentWORDFolder.foldNext
|
val fStart = EndOfCurrentWORDFolder.foldNext
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
structure EndOfCurrentWORDForDelete =
|
||||||
|
MakeNextDfaLoopPlus1
|
||||||
|
(struct
|
||||||
|
val startState = startState
|
||||||
|
|
||||||
|
structure Folder =
|
||||||
|
MakeCharFolderNext
|
||||||
|
(struct
|
||||||
|
val startState = startState
|
||||||
|
val tables = tables
|
||||||
|
|
||||||
|
fun isFinal currentState =
|
||||||
|
currentState = spaceAfterNonBlankState
|
||||||
|
fun finish idx = idx
|
||||||
|
end)
|
||||||
|
|
||||||
|
val fStart = Folder.foldNext
|
||||||
|
end)
|
||||||
|
|
||||||
structure EndOfCurrentWORDStrict =
|
structure EndOfCurrentWORDStrict =
|
||||||
MakeNextDfaLoop
|
MakeNextDfaLoop
|
||||||
(struct
|
(struct
|
||||||
@@ -138,6 +157,7 @@ struct
|
|||||||
val startOfCurrentWORD = StartOfCurrentWORD.prev
|
val startOfCurrentWORD = StartOfCurrentWORD.prev
|
||||||
(* E *)
|
(* E *)
|
||||||
val endOfCurrentWORD = EndOfCurrentWORD.next
|
val endOfCurrentWORD = EndOfCurrentWORD.next
|
||||||
|
val endOfCurrentWORDForDelete = EndOfCurrentWORDForDelete.next
|
||||||
|
|
||||||
(* functions to strictly get the start and end of the current word.
|
(* functions to strictly get the start and end of the current word.
|
||||||
* Problem: We want to support Vi motions like viW (selects a single word),
|
* Problem: We want to support Vi motions like viW (selects a single word),
|
||||||
|
|||||||
@@ -77,15 +77,6 @@ struct
|
|||||||
, spaceToPunctTable
|
, spaceToPunctTable
|
||||||
]
|
]
|
||||||
|
|
||||||
fun next (currentState, chr) =
|
|
||||||
let
|
|
||||||
val currentState = Word8.toInt currentState
|
|
||||||
val currentTable = Vector.sub (tables, currentState)
|
|
||||||
val charIdx = Char.ord chr
|
|
||||||
in
|
|
||||||
Vector.sub (currentTable, charIdx)
|
|
||||||
end
|
|
||||||
|
|
||||||
structure StartOfNextWord =
|
structure StartOfNextWord =
|
||||||
MakeNextDfaLoop
|
MakeNextDfaLoop
|
||||||
(struct
|
(struct
|
||||||
@@ -157,16 +148,17 @@ struct
|
|||||||
val fStart = StartOfCurrentWordFolder.foldPrev
|
val fStart = StartOfCurrentWordFolder.foldPrev
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
fun isFinalForEndOfCurrentWord currentState =
|
||||||
|
currentState = alphaToSpace orelse currentState = punctToSpace
|
||||||
|
orelse currentState = alphaToPunct orelse currentState = punctToAlpha
|
||||||
|
|
||||||
structure EndOfCurrentWordFolder =
|
structure EndOfCurrentWordFolder =
|
||||||
MakeCharFolderNext
|
MakeCharFolderNext
|
||||||
(struct
|
(struct
|
||||||
val startState = startState
|
val startState = startState
|
||||||
val tables = tables
|
val tables = tables
|
||||||
|
|
||||||
fun isFinal currentState =
|
val isFinal = isFinalForEndOfCurrentWord
|
||||||
currentState = alphaToSpace orelse currentState = punctToSpace
|
|
||||||
orelse currentState = alphaToPunct orelse currentState = punctToAlpha
|
|
||||||
|
|
||||||
fun finish x = x - 1
|
fun finish x = x - 1
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -184,6 +176,24 @@ struct
|
|||||||
val fStart = EndOfCurrentWordFolder.foldNext
|
val fStart = EndOfCurrentWordFolder.foldNext
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
structure EndOfCurrentWordForDelete =
|
||||||
|
MakeNextDfaLoopPlus1
|
||||||
|
(struct
|
||||||
|
val startState = startState
|
||||||
|
|
||||||
|
structure Folder =
|
||||||
|
MakeCharFolderNext
|
||||||
|
(struct
|
||||||
|
val startState = startState
|
||||||
|
val tables = tables
|
||||||
|
|
||||||
|
val isFinal = isFinalForEndOfCurrentWord
|
||||||
|
fun finish x = x
|
||||||
|
end)
|
||||||
|
|
||||||
|
val fStart = Folder.foldNext
|
||||||
|
end)
|
||||||
|
|
||||||
(* w *)
|
(* w *)
|
||||||
val startOfNextWord = StartOfNextWord.next
|
val startOfNextWord = StartOfNextWord.next
|
||||||
(* ge *)
|
(* ge *)
|
||||||
@@ -192,6 +202,7 @@ struct
|
|||||||
val startOfCurrentWord = StartOfCurrentWord.prev
|
val startOfCurrentWord = StartOfCurrentWord.prev
|
||||||
(* e *)
|
(* e *)
|
||||||
val endOfCurrentWord = EndOfCurrentWord.next
|
val endOfCurrentWord = EndOfCurrentWord.next
|
||||||
|
val endOfCurrentWordForDelete = EndOfCurrentWordForDelete.next
|
||||||
|
|
||||||
(* the meaning of "Strict" and the utility of these two functions
|
(* the meaning of "Strict" and the utility of these two functions
|
||||||
* is described in vi-WORD-dfa.sml *)
|
* is described in vi-WORD-dfa.sml *)
|
||||||
|
|||||||
@@ -729,9 +729,11 @@ struct
|
|||||||
|
|
||||||
(* equivalent of vi's `e` command *)
|
(* equivalent of vi's `e` command *)
|
||||||
val endOfWord = ViWordDfa.endOfCurrentWord
|
val endOfWord = ViWordDfa.endOfCurrentWord
|
||||||
|
val endOfWordForDelete = ViWordDfa.endOfCurrentWordForDelete
|
||||||
|
|
||||||
(* equivalent of vi's `E` command *)
|
(* equivalent of vi's `E` command *)
|
||||||
val endOfWORD = ViWORDDfa.endOfCurrentWORD
|
val endOfWORD = ViWORDDfa.endOfCurrentWORD
|
||||||
|
val endOfWORDForDelete = ViWORDDfa.endOfCurrentWORDForDelete
|
||||||
|
|
||||||
fun helpFirstNonSpaceChr (strPos, str, absIdx, stl, ltl) =
|
fun helpFirstNonSpaceChr (strPos, str, absIdx, stl, ltl) =
|
||||||
if strPos = String.size str then
|
if strPos = String.size str then
|
||||||
|
|||||||
Reference in New Issue
Block a user