Skip to content

Commit fabce33

Browse files
committed
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: doomemacs#8198
1 parent 3a9d607 commit fabce33

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

modules/emacs/undo/config.el

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,24 @@
2121
(define-key map (kbd "C-x r U") #'undo-fu-session-recover)
2222
map)
2323
:init-value nil
24-
:global t))
24+
:global t)
25+
26+
;; HACK: If undo-tree creates its diff window next to a popup/side window, the
27+
;; `balance-window' calls in `undo-tree-visualizer-update-diff' can wreck
28+
;; havoc on the window tree, making the diff window an unclosable "root"
29+
;; window (which emacs will happily throw errors about when you call
30+
;; `undo-tree-visualizer-quit'). Breakage ensues.
31+
;; REVIEW: Should be reported/addressed upstream, in undo-tree!
32+
(defadvice! +undo-tree--show-visualizer-diff-safely-a (&optional node)
33+
:override #'undo-tree-visualizer-show-diff
34+
(setq undo-tree-visualizer-diff t)
35+
(let ((buff (with-current-buffer undo-tree-visualizer-parent-buffer
36+
(with-current-buffer (undo-tree-diff node)
37+
(hide-mode-line-mode +1))))
38+
(display-buffer-mark-dedicated 'soft)
39+
(win (split-window (get-buffer-window undo-tree-visualizer-parent-buffer))))
40+
(set-window-buffer win buff)
41+
(shrink-window-if-larger-than-buffer win))))
2542

2643

2744
(use-package! undo-fu-session

0 commit comments

Comments
 (0)