From bc952d5c6f3d82eef674010147d7133c6f21084c Mon Sep 17 00:00:00 2001 From: Tom Dalziel Date: Sun, 24 Mar 2024 18:28:02 +0100 Subject: [PATCH] Handle args-out-of-range error in evil-repeat-start Fixes #1110 --- evil-repeat.el | 2 +- evil-tests.el | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/evil-repeat.el b/evil-repeat.el index df00d8f6..f840fb16 100644 --- a/evil-repeat.el +++ b/evil-repeat.el @@ -141,7 +141,7 @@ (when (evil-visual-state-p) (let* ((range (evil-visual-range)) (beg (evil-range-beginning range)) - (end (1- (evil-range-end range))) + (end (max 1 (1- (evil-range-end range)))) (nfwdlines (evil-count-lines beg end))) (evil-repeat-record (cond diff --git a/evil-tests.el b/evil-tests.el index 8dfaf1d1..80046332 100644 --- a/evil-tests.el +++ b/evil-tests.el @@ -1310,7 +1310,12 @@ evil\nrulz\nevil\nrulz\nevil\nrulz\nevil\nrulz\nevil\nrul[z] ("10IABC" [escape]) "ABCABCABCABCABCABCABCABCABCAB[C];; This buffer is for notes" ("11.") - "ABCABCABCABCABCABCABCABCABCABCAB[C]ABCABCABCABCABCABCABCABCABCABC;; This buffer is for notes"))) + "ABCABCABCABCABCABCABCABCABCABCAB[C]ABCABCABCABCABCABCABCABCABCABC;; This buffer is for notes")) + (ert-info ("Repeat insert over empty lines") + (evil-test-buffer + "" + ("i" [return] [return] [return] [return] [return] [return] [escape] "gg\C-vGIX" [escape]) + "X\nX\nX\nX\nX\nX\n"))) (ert-deftest evil-test-insert-line-vcount () "Test `evil-insert-line' with vertical repeating" @@ -1370,7 +1375,12 @@ ABCABC{ ("10AABC" [escape]) ";; This buffer is for notes.ABCABCABCABCABCABCABCABCABCAB[C]" ("11.") - ";; This buffer is for notes.ABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCAB[C]"))) + ";; This buffer is for notes.ABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCAB[C]")) + (ert-info ("Repeat append over empty lines") + (evil-test-buffer + "" + ("i" [return] [return] [return] [return] [return] [return] [escape] "gg\C-vGAX" [escape]) + "X\nX\nX\nX\nX\nX\n"))) (ert-deftest evil-test-append-line-vcount () "Test `evil-append-line' with vertical repeating"