diff options
| author | Axel Forsman <axelsfor@gmail.com> | 2022-11-15 15:52:42 +0100 |
|---|---|---|
| committer | Tom Dalziel <33435574+tomdl89@users.noreply.github.com> | 2022-12-29 17:38:43 +0000 |
| commit | be6b09bcecf3bfdbaadecb21f31c57ce18abac05 (patch) | |
| tree | a5a9ec3eeb07767922e035dbd9d96183f5717e4e /evil-states.el | |
| parent | 0c535d6dabb9f30ab16ab428c9a123dba9d6ef75 (diff) | |
Make visual block selection after j/k match Vim
Vim only extends the visual block selection to the temporary goal column
if tracking EOL. Consider
[a]bc
a
When entering Visual block mode with "C-v", going to the "c" in "abc"
and then to the next line with "fcj", the selection should only include
the two "a":s, and not "bc". Contrast this with when "$" is executed.
Diffstat (limited to 'evil-states.el')
| -rw-r--r-- | evil-states.el | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/evil-states.el b/evil-states.el index 4d87323..a7242c2 100644 --- a/evil-states.el +++ b/evil-states.el @@ -646,10 +646,6 @@ Reuse overlays where possible to prevent flicker." (let* ((point (point)) (overlays (or overlays 'evil-visual-block-overlays)) (old (symbol-value overlays)) - (eol-col (and (memq this-command '(next-line previous-line)) - (numberp temporary-goal-column) - (1+ (min (round temporary-goal-column) - (1- most-positive-fixnum))))) beg-col end-col new nlines overlay window-beg window-end) (save-excursion ;; calculate the rectangular region represented by BEG and END, @@ -660,16 +656,13 @@ Reuse overlays where possible to prevent flicker." (when (>= beg-col end-col) (if (= beg-col end-col) (setq end-col (1+ end-col)) - (evil-sort beg-col end-col)) - (setq beg (save-excursion - (goto-char beg) - (evil-move-to-column beg-col)) - end (save-excursion - (goto-char end) - (evil-move-to-column end-col 1)))) - ;; update end column with eol-col (extension to eol). - (when (and eol-col (> eol-col end-col)) - (setq end-col eol-col)) + (evil-swap beg-col end-col)) + (setq beg (progn (goto-char beg) (evil-move-to-column beg-col)) + end (progn (goto-char end) (evil-move-to-column end-col 1)))) + ;; maybe extend end column to EOL + (and (memq this-command '(next-line previous-line)) + (eq temporary-goal-column most-positive-fixnum) + (setq end-col most-positive-fixnum)) ;; force a redisplay so we can do reliable window ;; BEG/END calculations (sit-for 0) |
