diff options
| author | Tom Dalziel <33435574+tomdl89@users.noreply.github.com> | 2022-10-24 17:56:04 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-24 17:56:04 +0200 |
| commit | 88da852e3df2fa6a4b03ea5ed7e6dc4a1aef6c15 (patch) | |
| tree | 2ff7432bb904773d09ca492c3a052b53f6587e21 /evil-states.el | |
| parent | a13a05f263dd54632d4509e7cfb2bb5df556d442 (diff) | |
evil transient mouse selection (#1706)
Diffstat (limited to 'evil-states.el')
| -rw-r--r-- | evil-states.el | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/evil-states.el b/evil-states.el index 9686062..0c932e6 100644 --- a/evil-states.el +++ b/evil-states.el @@ -248,6 +248,7 @@ the selection is enabled. (if (and (evil-visual-state-p) (eq evil-visual-selection ',selection)) 'exit ,name) t)) + (setq evil--region-from-mouse nil) (if (eq type 'exit) (evil-exit-visual-state) (setq type (or type ,name) @@ -325,15 +326,25 @@ the selection is enabled. Expand the region to the selection unless COMMAND is a motion." (when (evil-visual-state-p) (setq command (or command this-command)) - (when evil-visual-x-select-timer - (cancel-timer evil-visual-x-select-timer)) - (unless (evil-get-command-property command :keep-visual) - (evil-visual-update-x-selection) - (evil-visual-expand-region - ;; exclude final newline from linewise selection - ;; unless the command has real need of it - (and (eq (evil-visual-type) 'line) - (evil-get-command-property command :exclude-newline)))))) + (if (and evil-transient-mouse-selection + evil--region-from-mouse + (not (rassq command evil-visual-alist))) + (progn (setq evil--region-from-mouse nil) + (evil-exit-visual-state)) + (when (and evil-transient-mouse-selection + evil--region-from-mouse + (rassq command evil-visual-alist)) + (setq evil-visual-selection nil ;; maintain visual state + evil--region-from-mouse nil)) + (when evil-visual-x-select-timer + (cancel-timer evil-visual-x-select-timer)) + (unless (evil-get-command-property command :keep-visual) + (evil-visual-update-x-selection) + (evil-visual-expand-region + ;; exclude final newline from linewise selection + ;; unless the command has real need of it + (and (eq (evil-visual-type) 'line) + (evil-get-command-property command :exclude-newline))))))) (put 'evil-visual-pre-command 'permanent-local-hook t) |
