fix(undo): undo-tree visualizer refusing to quit in some cases

This is due to other dedicated/side popups and/or windows causing the
undo-tree visualizer buffer to open in difficult-to-delete windows. This
should be reported and addressed upstream, though.

Fix: #8198
This commit is contained in:
Henrik Lissner
2025-05-15 14:31:23 +02:00
parent 3a9d6071f3
commit fabce333e0

View File

@ -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