Skip to content

Commit

Permalink
Record search offset for repeat
Browse files Browse the repository at this point in the history
Fixes #1907
  • Loading branch information
tomdl89 committed Jun 16, 2024
1 parent f29ad3c commit e72562f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 5 additions & 2 deletions evil-commands.el
Original file line number Diff line number Diff line change
Expand Up @@ -3800,12 +3800,15 @@ after executing the command."
(evil-repeat-record (this-command-keys))
(evil-clear-command-keys))
((and (evil-operator-state-p) (eq flag 'post))
(evil-repeat-record (evil-ex-pattern-regex evil-ex-search-pattern))
(let ((search-separator (car (last evil-repeat-info))))
(evil-repeat-record (evil-ex-pattern-regex evil-ex-search-pattern))
(when evil-ex-search-offset
(evil-repeat-record (concat search-separator evil-ex-search-offset))))
;; If it weren't for the fact that `exit-minibuffer' throws an `exit'
;; tag, which bypasses the source of `this-command-keys', we'd be able
;; to capture the key(s) in the post-command of the operator as usual.
;; Fortunately however, `last-input-event' can see the key (by default, `return')
(when (= (length (this-command-keys)) 0)
(when (zerop (length (this-command-keys)))
(evil-repeat-record (vector last-input-event))))
(t (evil-repeat-motion flag))))

Expand Down
10 changes: 9 additions & 1 deletion evil-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,15 @@ If nil, KEYS is used."
("i(\M-f)" [escape])
";; (This[)] buffer is for notes you don't want to save"
("w.")
";; (This) (buffer[)] is for notes you don't want to save")))
";; (This) (buffer[)] is for notes you don't want to save"))
(ert-info ("Repeat search motion with offset")
(evil-select-search-module 'evil-search-module 'evil-search)
(evil-test-buffer
"[f]irst, second, third, fourth"
("d/, /e" [return])
"[s]econd, third, fourth"
("2.")
"[f]ourth")))

(ert-deftest evil-test-repeat-register ()
"Test repeating a register command."
Expand Down

0 comments on commit e72562f

Please sign in to comment.