Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always undo in normal state #1888

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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