diff options
| -rw-r--r-- | evil-ex.el | 14 | ||||
| -rw-r--r-- | evil-tests.el | 28 | ||||
| -rw-r--r-- | evil-types.el | 2 |
3 files changed, 38 insertions, 6 deletions
@@ -814,8 +814,11 @@ Returns the line number of the match." (save-excursion (set-text-properties 0 (length pattern) nil pattern) (evil-move-end-of-line) - (and (re-search-forward pattern nil t) - (line-number-at-pos (1- (match-end 0)))))) + (if (re-search-forward pattern nil t) + (line-number-at-pos (1- (match-end 0))) + (goto-char (point-min)) + (and (re-search-forward pattern nil t) + (line-number-at-pos (1- (match-end 0))))))) (invalid-regexp (evil-ex-echo (cadr err)) nil))) @@ -828,8 +831,11 @@ Returns the line number of the match." (save-excursion (set-text-properties 0 (length pattern) nil pattern) (evil-move-beginning-of-line) - (and (re-search-backward pattern nil t) - (line-number-at-pos (match-beginning 0))))) + (if (re-search-backward pattern nil t) + (line-number-at-pos (match-beginning 0)) + (goto-char (point-max)) + (and (re-search-backward pattern nil t) + (line-number-at-pos (match-beginning 0)))))) (invalid-regexp (evil-ex-echo (cadr err)) nil))) diff --git a/evil-tests.el b/evil-tests.el index 70d2555..10f1ee4 100644 --- a/evil-tests.el +++ b/evil-tests.el @@ -7846,7 +7846,33 @@ maybe we need one line more with some text\n") (evil-test-buffer "line1\nline2\nline3\nli[n]e4\nline5\n" (":2,4move.") - "line1\nline2\nline3\n[l]ine4\nline5\n"))) + "line1\nline2\nline3\n[l]ine4\nline5\n")) + (ert-info ("Move to backwards line, searching forwards (wrapping around)") + (evil-test-buffer + " +Target +Other line +[S]ource +" + (":move/Target/") + " +Target +[S]ource +Other line +")) + (ert-info ("Move to forwards line, searching backwards (wrapping around)") + (evil-test-buffer + " +Target +[O]ther line +Source +" + (":move?Source?") + " +Target +Source +[O]ther line +"))) (ert-deftest evil-test-write () :tags '(evil ex) diff --git a/evil-types.el b/evil-types.el index fe4972b..22d01e8 100644 --- a/evil-types.el +++ b/evil-types.el @@ -380,7 +380,7 @@ If visual state is inactive then those values are nil." "Ex line number." (list (and (evil-ex-p) - (let ((expr (evil-ex-parse evil-ex-argument))) + (let ((expr (evil-ex-parse evil-ex-argument))) (if (eq (car expr) 'evil-goto-line) (save-excursion (goto-char evil-ex-point) |
