diff options
| author | Jakub Kadlcik <frostyx@email.cz> | 2023-02-10 16:54:55 +0100 |
|---|---|---|
| committer | Youmu <condy0919@gmail.com> | 2023-02-14 01:18:16 +0800 |
| commit | 5fbfc359b4a4fb2206130e02cf275a8a1872079e (patch) | |
| tree | 0cc89d47f87e1a160a4065d32783b234fb599900 /modes/vterm | |
| parent | 692fb0fc8678c555e26961dea1db5df37e151cf6 (diff) | |
vterm: prevent moving the cursor below the last prompt line by `j' button
It is not 100% bulletproof but we don't have any function telling us
the point or line number of the last prompt, and it doesn't seem to be
easy to implement, so I needed to workaround this.
Diffstat (limited to 'modes/vterm')
| -rw-r--r-- | modes/vterm/evil-collection-vterm.el | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/modes/vterm/evil-collection-vterm.el b/modes/vterm/evil-collection-vterm.el index 7cc9972..0ae150d 100644 --- a/modes/vterm/evil-collection-vterm.el +++ b/modes/vterm/evil-collection-vterm.el @@ -213,6 +213,16 @@ Save in REGISTER or in the kill-ring with YANK-HANDLER." (interactive "<r><x>") (evil-collection-vterm-change beg end 'line register yank-handler)) +(evil-define-motion evil-collection-vterm-next-line (count) + "Move the cursor COUNT lines down. +But don't allow the cursor to move bellow the last prompt line." + :type line + ;; This successfully prevents the `j' button from moving to an empty line + ;; bellow the last prompt. However, it still can be bugged for example by + ;; going to the one line above the last prompt and doing `10j'. + (when (> (count-words (point) (point-max)) 0) + (evil-next-line count))) + ;;;###autoload (defun evil-collection-vterm-setup () "Set up `evil' bindings for `vterm'." @@ -267,7 +277,8 @@ Save in REGISTER or in the kill-ring with YANK-HANDLER." "c" 'evil-collection-vterm-change "C" 'evil-collection-vterm-change-line "s" 'evil-collection-vterm-substitute - "S" 'evil-collection-vterm-substitute-line) + "S" 'evil-collection-vterm-substitute-line + "j" 'evil-collection-vterm-next-line) (evil-collection-define-key 'visual 'vterm-mode-map "d" 'evil-collection-vterm-delete |
