diff --git a/modules/emacs/undo/config.el b/modules/emacs/undo/config.el index d706ac5c4..e9ed30895 100644 --- a/modules/emacs/undo/config.el +++ b/modules/emacs/undo/config.el @@ -21,7 +21,24 @@ (define-key map (kbd "C-x r U") #'undo-fu-session-recover) map) :init-value nil - :global t)) + :global t) + + ;; HACK: If undo-tree creates its diff window next to a popup/side window, the + ;; `balance-window' calls in `undo-tree-visualizer-update-diff' can wreck + ;; havoc on the window tree, making the diff window an unclosable "root" + ;; window (which emacs will happily throw errors about when you call + ;; `undo-tree-visualizer-quit'). Breakage ensues. + ;; REVIEW: Should be reported/addressed upstream, in undo-tree! + (defadvice! +undo-tree--show-visualizer-diff-safely-a (&optional node) + :override #'undo-tree-visualizer-show-diff + (setq undo-tree-visualizer-diff t) + (let ((buff (with-current-buffer undo-tree-visualizer-parent-buffer + (with-current-buffer (undo-tree-diff node) + (hide-mode-line-mode +1)))) + (display-buffer-mark-dedicated 'soft) + (win (split-window (get-buffer-window undo-tree-visualizer-parent-buffer)))) + (set-window-buffer win buff) + (shrink-window-if-larger-than-buffer win)))) (use-package! undo-fu-session