aboutsummaryrefslogtreecommitdiff
path: root/evil-commands.el
diff options
context:
space:
mode:
authorTom Dalziel <tom_dl@hotmail.com>2024-04-01 00:16:23 +0200
committerTom Dalziel <tom_dl@hotmail.com>2024-04-01 00:16:23 +0200
commit004ac4e0cd766d49d48d53270e9c0c080ad9f173 (patch)
tree10decd0c966b810c7cb689d7ca59da52615f9d73 /evil-commands.el
parent476f5fbcf1288c5a46a6ba35efe0b8dd1e4dd0ec (diff)
Don't miss a final empty line in visual block insertion
Diffstat (limited to 'evil-commands.el')
-rw-r--r--evil-commands.el27
1 files changed, 16 insertions, 11 deletions
diff --git a/evil-commands.el b/evil-commands.el
index 9494030..150ac04 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