Skip to content

Commit e1b98d4

Browse files
axelf4tomdl89
andauthored
Fix evil-find-char on empty line (#1475)
Previously, with the cursor on an empty line `evil-find-char` would continue searching on the next line. This was because `forward-char` would advance to the next line, after which the `search-forward` bound would be wrongly calculated. Co-authored-by: Tom Dalziel <tom_dl@hotmail.com>
1 parent 7560832 commit e1b98d4

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

evil-commands.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ Movement is restricted to the current line unless `evil-cross-lines' is non-nil.
766766
(visual (and evil-respect-visual-line-mode
767767
visual-line-mode)))
768768
(setq evil-last-find (list #'evil-find-char char fwd))
769-
(when fwd (forward-char))
769+
(when fwd (evil-forward-char 1 evil-cross-lines))
770770
(let ((case-fold-search nil))
771771
(unless (prog1
772772
(search-forward (char-to-string char)

evil-tests.el

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5164,7 +5164,12 @@ Below some empty line."))
51645164
;; and for Lisp evaluation."
51655165
("fL")
51665166
";; This buffer is for notes,
5167-
;; and for [L]isp evaluation."))))
5167+
;; and for [L]isp evaluation.")))
5168+
(ert-info ("Empty line")
5169+
(evil-test-buffer
5170+
"[]
5171+
This buffer is for notes."
5172+
(should-error (execute-kbd-macro "fT")))))
51685173

51695174
(ert-deftest evil-test-find-char-backward ()
51705175
"Test `evil-find-char-backward'"

0 commit comments

Comments
 (0)