[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil 9f25e190c3: Make sure to restore state after executin
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil 9f25e190c3: Make sure to restore state after executing motion |
Date: |
Fri, 20 Jan 2023 15:59:25 -0500 (EST) |
branch: elpa/evil
commit 9f25e190c360dc65dbcdfaef3d6408eedd5921d9
Author: Axel Forsman <axelsfor@gmail.com>
Commit: Axel Forsman <axelsfor@gmail.com>
Make sure to restore state after executing motion
This fixes a regression caused by commit
29a5d464e973b66abae20e6c4b402a366547c7a5.
Resolves #1756
---
evil-macros.el | 71 +++++++++++++++++++++++++++++-----------------------------
evil-tests.el | 6 +++++
2 files changed, 41 insertions(+), 36 deletions(-)
diff --git a/evil-macros.el b/evil-macros.el
index 4631a998e7..1ba6e51c18 100644
--- a/evil-macros.el
+++ b/evil-macros.el
@@ -588,8 +588,8 @@ RETURN-TYPE is non-nil."
(or evil-this-type 'exclusive))))
;; motion
(t
- (unless motion
- (evil-save-state
+ (evil-save-state
+ (unless motion
;; Make linewise operator shortcuts. E.g., "d" yields the
;; shortcut "dd", and "g?" yields shortcuts "g??" and "g?g?".
(let ((keys (nth 2 (evil-extract-count (this-command-keys)))))
@@ -601,36 +601,36 @@ RETURN-TYPE is non-nil."
(let ((command (evil-read-motion motion)))
(setq motion (car command)
count (cadr command)
- type (or type (nth 2 command))))))
- (cond
- ((eq motion #'undefined)
- (setq range (list nil nil)
- motion nil))
- ((or (null motion) ; keyboard-quit
- (evil-get-command-property motion :suppress-operator))
- (evil-repeat-abort)
- (setq quit-flag t
- range (evil-range (point) (point)) ; zero-len range
- motion nil))
- (evil-repeat-count
- (setq count evil-repeat-count
- ;; only the first operator's count is overwritten
- evil-repeat-count nil))
- ((or count current-prefix-arg)
- ;; multiply operator count and motion count together
- (setq count
- (* (prefix-numeric-value count)
- (prefix-numeric-value current-prefix-arg)))))
- (when motion
- (let ((evil-state 'operator)
- mark-active)
- ;; calculate motion range
- (setq range (evil-motion-range motion count type))))
- ;; update global variables
- (setq evil-this-motion motion
- evil-this-motion-count count
- type (evil-type range type)
- evil-this-type type))))
+ type (or type (nth 2 command)))))
+ (cond
+ ((eq motion #'undefined)
+ (setq range (list nil nil)
+ motion nil))
+ ((or (null motion) ; keyboard-quit
+ (evil-get-command-property motion :suppress-operator))
+ (evil-repeat-abort)
+ (setq quit-flag t
+ range (evil-range (point) (point)) ; zero-len range
+ motion nil))
+ (evil-repeat-count
+ (setq count evil-repeat-count
+ ;; only the first operator's count is overwritten
+ evil-repeat-count nil))
+ ((or count current-prefix-arg)
+ ;; multiply operator count and motion count together
+ (setq count
+ (* (prefix-numeric-value count)
+ (prefix-numeric-value current-prefix-arg)))))
+ (when motion
+ (let ((evil-state 'operator)
+ mark-active)
+ ;; calculate motion range
+ (setq range (evil-motion-range motion count type))))
+ ;; update global variables
+ (setq evil-this-motion motion
+ evil-this-motion-count count
+ type (evil-type range type)
+ evil-this-type type)))))
(unless (or (null type) (eq (evil-type range) type))
(evil-contract-range range)
(evil-set-range-type range type)
@@ -638,10 +638,9 @@ RETURN-TYPE is non-nil."
(setq evil-operator-range-beginning (evil-range-beginning range)
evil-operator-range-end (evil-range-end range)
evil-operator-range-type (evil-type range))
- (if return-type
- (list (car range) (cadr range) (evil-type range))
- (setcdr (cdr range) nil)
- range)))
+ (setcdr (cdr range)
+ (when return-type (list (evil-type range))))
+ range))
(defmacro evil-define-type (type doc &rest body)
"Define type TYPE.
diff --git a/evil-tests.el b/evil-tests.el
index 159e3a7452..a32954d1cb 100644
--- a/evil-tests.el
+++ b/evil-tests.el
@@ -2514,6 +2514,12 @@ Below some empty line")))
("^`[")
"alpha b[r]")))
+(ert-deftest evil-test-operator-save-state-for-motion ()
+ "Test that `evil-operator-range' restores state after executing motion."
+ (evil-test-buffer "abc"
+ ("dfbix" [escape])
+ "xc"))
+
;;; Paste
(ert-deftest evil-test-paste-before ()
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] elpa/evil 9f25e190c3: Make sure to restore state after executing motion,
ELPA Syncer <=