implement 'dG' motion (need to test it next)
This commit is contained in:
@@ -727,10 +727,7 @@ struct
|
|||||||
|
|
||||||
val buffer = LineGap.delete (0, cursorIdx, buffer)
|
val buffer = LineGap.delete (0, cursorIdx, buffer)
|
||||||
val buffer =
|
val buffer =
|
||||||
if #textLength buffer = 0 then
|
if #textLength buffer = 0 then LineGap.fromString "\n" else buffer
|
||||||
LineGap.fromString "\n"
|
|
||||||
else
|
|
||||||
buffer
|
|
||||||
val buffer = LineGap.goToStart buffer
|
val buffer = LineGap.goToStart buffer
|
||||||
val initialMsg = SEARCH (buffer, dfa, time) :: initialMsg
|
val initialMsg = SEARCH (buffer, dfa, time) :: initialMsg
|
||||||
|
|
||||||
@@ -771,6 +768,35 @@ struct
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fun deleteToEnd (app: app_type, time) =
|
||||||
|
let
|
||||||
|
val {buffer, cursorIdx, ...} = app
|
||||||
|
|
||||||
|
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||||
|
val startOfLineIdx = Cursor.vi0 (buffer, cursorIdx)
|
||||||
|
val length = #textLength buffer - startOfLineIdx
|
||||||
|
|
||||||
|
val buffer = LineGap.goToIdx (#textLength buffer, buffer)
|
||||||
|
val initialMsg = Fn.initMsgs (startOfLineIdx, length, buffer)
|
||||||
|
|
||||||
|
val buffer = LineGap.delete (startOfLineIdx, length, buffer)
|
||||||
|
val buffer =
|
||||||
|
if #textLength buffer = 0 then LineGap.fromString "\n" else buffer
|
||||||
|
|
||||||
|
val newLineEndIdx = Int.max (startOfLineIdx - 1, 0)
|
||||||
|
val buffer = LineGap.goToIdx (newLineEndIdx, buffer)
|
||||||
|
val newLineEndIdx =
|
||||||
|
if Cursor.isOnNewlineAfterChr (buffer, newLineEndIdx) then
|
||||||
|
Int.max (newLineEndIdx - 1, 0)
|
||||||
|
else
|
||||||
|
newLineEndIdx
|
||||||
|
|
||||||
|
val buffer = LineGap.goToIdx (newLineEndIdx, buffer)
|
||||||
|
val newLineStartIdx = Cursor.vi0 (buffer, newLineEndIdx)
|
||||||
|
in
|
||||||
|
finishAfterDeletingBuffer (app, newLineStartIdx, buffer, time, initialMsg)
|
||||||
|
end
|
||||||
|
|
||||||
fun helpDeleteToMatch (app: app_type, low, high, time) =
|
fun helpDeleteToMatch (app: app_type, low, high, time) =
|
||||||
let
|
let
|
||||||
val {buffer, dfa, ...} = app
|
val {buffer, dfa, ...} = app
|
||||||
|
|||||||
@@ -274,6 +274,7 @@ struct
|
|||||||
| #"n" => NormalDelete.deleteToNextMatch (app, count, time)
|
| #"n" => NormalDelete.deleteToNextMatch (app, count, time)
|
||||||
| #"N" => NormalDelete.deleteToPrevMatch (app, count, time)
|
| #"N" => NormalDelete.deleteToPrevMatch (app, count, time)
|
||||||
| #"%" => NormalDelete.deletePair (app, time)
|
| #"%" => NormalDelete.deletePair (app, time)
|
||||||
|
| #"G" => NormalDelete.deleteToEnd (app, time)
|
||||||
(* non-terminal commands which require appending chr *)
|
(* non-terminal commands which require appending chr *)
|
||||||
| #"t" => appendChr (app, chrCmd, str)
|
| #"t" => appendChr (app, chrCmd, str)
|
||||||
| #"T" => appendChr (app, chrCmd, str)
|
| #"T" => appendChr (app, chrCmd, str)
|
||||||
|
|||||||
2
todo.md
2
todo.md
@@ -1,6 +1,7 @@
|
|||||||
# To-do list
|
# To-do list
|
||||||
|
|
||||||
- Add tests for:
|
- Add tests for:
|
||||||
|
- `dG`
|
||||||
- `d$`
|
- `d$`
|
||||||
- `d^`
|
- `d^`
|
||||||
- `dd`
|
- `dd`
|
||||||
@@ -18,6 +19,5 @@
|
|||||||
- Reimplement `di<symbol>` and `da<symbol>`
|
- Reimplement `di<symbol>` and `da<symbol>`
|
||||||
- They should search for the next char in the specific pair, the same way in Vim
|
- They should search for the next char in the specific pair, the same way in Vim
|
||||||
- Add tests for both
|
- Add tests for both
|
||||||
- Implement `dG` motion and test it
|
|
||||||
|
|
||||||
Afterwards, add tests for yanking.
|
Afterwards, add tests for yanking.
|
||||||
|
|||||||
Reference in New Issue
Block a user