Skip to content

Commit c44ffde

Browse files
authored
Merge pull request #1691 from sakurawald/fix-vi-insert-command-keys-for-insert-mode
fix: the vi-insert mode should insert the pending-keys (the length of command-keys > 1) for self-insert command.
2 parents c99ba65 + cd01533 commit c44ffde

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

extensions/vi-mode/vi-mode.lisp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,25 @@
6666
(fall-within-line (current-point)))
6767

6868
(defmethod post-command-hook ((state insert))
69-
(let ((command (this-command)))
69+
(let* ((command (this-command))
70+
(this-command-keys (vi-this-command-keys))
71+
(pending-keys (cdr this-command-keys)))
72+
73+
;; For the command `self-insert`, the `this-command-keys` is typically only 1 char. (pending-keys = nil)
74+
;; If pending-keys is NOT nil, then these keys are used to disguish the keys between `self-insert` command and other commands.
75+
;; For other commands, we can simply ignore the pending-keys.
76+
;; For self-insert command, we should also flusthese pending-keys.
77+
(when (and
78+
(typep command 'self-insert)
79+
pending-keys)
80+
(dolist (key pending-keys) (self-insert 1 (key-to-char key))))
81+
7082
(when *enable-repeat-recording*
7183
(unless (or (and (typep command 'vi-command)
7284
(eq (vi-command-repeat command) nil))
7385
(eq (command-name (this-command)) 'vi-end-insert))
7486
(appendf *last-repeat-keys*
75-
(vi-this-command-keys)))))
87+
this-command-keys))))
7688
(adjust-window-scroll))
7789

7890
(defmethod post-command-hook :after ((state visual))

0 commit comments

Comments
 (0)