diff --git a/modules/editor/evil/config.el b/modules/editor/evil/config.el index e99caec42..5315d3f5c 100644 --- a/modules/editor/evil/config.el +++ b/modules/editor/evil/config.el @@ -55,6 +55,14 @@ directives. By default, this only recognizes C directives.") ((modulep! :emacs undo) 'undo-fu) ((> emacs-major-version 27) 'undo-redo))) + ;; Fix #7141 + (defadvice! +evil--persist-state-a (fn &rest args) + "When changing major modes, Evil's state is lost. This advice preserves it." + :around #'set-auto-mode + (if evil-state + (evil-save-state (apply fn args)) + (apply fn args))) + ;; Slow this down from 0.02 to prevent blocking in large or folded buffers ;; like magit while incrementally highlighting matches. (setq-hook! '(magit-mode-hook so-long-minor-mode-hook)