From 825758cc718ee1ef5d4163636ff3caf2a2c0cf20 Mon Sep 17 00:00:00 2001 From: Tom Dalziel Date: Sun, 16 Jun 2024 16:13:28 +0200 Subject: [PATCH] Record search offset for repeat Fixes #1907 --- evil-commands.el | 7 +++++-- evil-tests.el | 10 +++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/evil-commands.el b/evil-commands.el index 43030c22..e4fe002b 100644 --- a/evil-commands.el +++ b/evil-commands.el @@ -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)))) diff --git a/evil-tests.el b/evil-tests.el index 4699108a..ab49676f 100644 --- a/evil-tests.el +++ b/evil-tests.el @@ -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."