branch: elpa/evil commit 004ac4e0cd766d49d48d53270e9c0c080ad9f173 Author: Tom Dalziel <tom...@hotmail.com> Commit: Tom Dalziel <tom...@hotmail.com>
Don't miss a final empty line in visual block insertion --- evil-commands.el | 27 ++++++++++++++++----------- evil-tests.el | 2 +- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/evil-commands.el b/evil-commands.el index 9494030fad..150ac04652 100644 --- a/evil-commands.el +++ b/evil-commands.el @@ -2676,17 +2676,22 @@ If SKIP-EMPTY-LINES is non-nil, the insertion will not be performed on lines on which the insertion point would be after the end of the lines. This is the default behaviour for Visual-state insertion." (interactive - (list (prefix-numeric-value current-prefix-arg) - (and (evil-visual-state-p) - (memq (evil-visual-type) '(line block)) - (save-excursion - (let ((m (mark))) - ;; go to upper-left corner temporarily so - ;; `count-lines' yields accurate results - (evil-visual-rotate 'upper-left) - (prog1 (count-lines evil-visual-beginning evil-visual-end) - (set-mark m))))) - (evil-visual-state-p))) + (let ((lines+ 0)) + (list (prefix-numeric-value current-prefix-arg) + (and (evil-visual-state-p) + (memq (evil-visual-type) '(line block)) + (save-excursion + (let ((m (mark))) + (evil-visual-rotate 'lower-right) + ;; count-lines misses an empty final line, so correct that + (and (bolp) (eolp) (setq lines+ 1)) + ;; go to upper-left corner temporarily so + ;; `count-lines' yields accurate results + (evil-visual-rotate 'upper-left) + (prog1 (+ (count-lines evil-visual-beginning evil-visual-end) + lines+) + (set-mark m))))) + (evil-visual-state-p)))) (if (and (called-interactively-p 'any) (evil-visual-state-p)) (cond diff --git a/evil-tests.el b/evil-tests.el index 4650710c3a..8ca961fcef 100644 --- a/evil-tests.el +++ b/evil-tests.el @@ -1315,7 +1315,7 @@ evil\nrulz\nevil\nrulz\nevil\nrulz\nevil\nrulz\nevil\nrul[z] (evil-test-buffer "" ("i" [return] [return] [return] [return] [return] [return] [escape] "gg\C-vGIX" [escape]) - "X\nX\nX\nX\nX\nX\n"))) + "X\nX\nX\nX\nX\nX\nX"))) (ert-deftest evil-test-insert-line-vcount () "Test `evil-insert-line' with vertical repeating"