aboutsummaryrefslogtreecommitdiff
path: root/evil-commands.el
diff options
context:
space:
mode:
authorTom Dalziel <tom_dl@hotmail.com>2024-06-04 09:38:55 +0200
committerTom Dalziel <33435574+tomdl89@users.noreply.github.com>2024-06-14 18:21:16 +0200
commitf29ad3c91e06ca1910f326b3b0a41ae59ba2c8b6 (patch)
tree5117d95ad9f59d3461a7f303aee59e61228eb9f7 /evil-commands.el
parenta32f016536fadf5080be39f239288b76146216ee (diff)
Track (and restore) previous visual selection, point, mark for gv
Diffstat (limited to 'evil-commands.el')
-rw-r--r--evil-commands.el34
1 files changed, 20 insertions, 14 deletions
diff --git a/evil-commands.el b/evil-commands.el
index 1278c61..43030c2 100644
--- a/evil-commands.el
+++ b/evil-commands.el
@@ -2579,20 +2579,26 @@ COUNT is infinite."
(evil-define-motion evil-visual-restore ()
"Restore previous selection."
- (let* ((point (point))
- (mark (or (mark t) point))
- (type (evil-visual-type)))
- ;; TODO handle swapping selection in visual state...
- (unless (evil-visual-state-p)
- (cond
- ;; No previous selection.
- ((or (null evil-visual-selection)
- (null evil-visual-mark)
- (null evil-visual-point)))
- (t
- (setq mark evil-visual-mark
- point evil-visual-point)
- (evil-visual-make-selection mark point type t))))))
+ (cond
+ ;; Called from visual state
+ ((and (evil-visual-state-p)
+ evil-prev-visual-mark evil-prev-visual-point evil-prev-visual-selection)
+ (let ((tmp-visual-mark (marker-position evil-visual-mark))
+ (tmp-visual-point (marker-position evil-visual-point))
+ (tmp-visual-selection evil-visual-selection))
+ (evil-visual-make-selection evil-prev-visual-mark
+ evil-prev-visual-point
+ evil-prev-visual-selection
+ t)
+ (move-marker evil-prev-visual-mark tmp-visual-mark)
+ (move-marker evil-prev-visual-point tmp-visual-point)
+ (setq evil-prev-visual-selection tmp-visual-selection)))
+ ;; Called from other state
+ ((and evil-visual-selection evil-visual-mark evil-visual-point)
+ (evil-visual-make-selection evil-visual-mark
+ evil-visual-point
+ (evil-visual-type)
+ t))))
(evil-define-motion evil-visual-exchange-corners ()
"Rearrange corners in Visual Block mode.