Skip to content

Commit

Permalink
Always undo in normal state (#1888)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomdl89 authored Apr 15, 2024
1 parent f4bacdd commit eae05b5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion evil-commands.el
Original file line number Diff line number Diff line change
Expand Up @@ -1778,7 +1778,10 @@ Add (add-hook 'evil-local-mode-hook 'turn-on-undo-tree-mode) to your init file f
:jump t
(interactive "*p")
(evil--check-undo-system)
(funcall evil-undo-function count))
(let ((state-before evil-state))
(unless (eq 'normal state-before) (evil-normal-state))
(funcall evil-undo-function count)
(unless (eq 'normal state-before) (evil-change-state state-before))))

(evil-define-command evil-redo (count)
"Undo COUNT changes in buffer using `evil-redo-function'."
Expand Down
14 changes: 14 additions & 0 deletions evil-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -9816,6 +9816,20 @@ when an error stops the execution of the macro"
("``")
"alpha bravo charlie [d]elta"))))

(ert-deftest evil-test-insert-state-undo ()
"Test that undo isn't lost when done from insert state."
:tags '(evil)
(skip-unless (version<= "28" emacs-version))
(let (evil-want-fine-undo)
(customize-set-variable 'evil-undo-system 'undo-redo)
(evil-test-buffer
"alpha [ ]delta"
(evil-define-key* 'insert 'local [f8] 'evil-undo)
("icharlie" [f8] [escape])
"alpha[ ] delta"
("\C-r")
"alpha [c]harlie delta")))

(ert-deftest evil-test-visual-update-x-selection ()
"Test `evil-visual-update-x-selection'."
:tags '(evil)
Expand Down

0 comments on commit eae05b5

Please sign in to comment.