Fix infinite redrawing/freezing with {centaur,awesome}-tabs
Caused by over-zealous doom-switch-window-hook. For my own sanity (and if you're curious), I'll break it down here: 1. Doom has a `doom-switch-window-hook` hook. It triggers when window focus is changed. 2. We use `buffer-list-update-hook` to trigger `doom-switch-window-hook`. (That may sound weird, but this hook is reliably executed when window focus is changed -- there are safeguards to prevent this from triggering too often) 3. `buffer-list-update-hook` triggers whenever a buffer is created, but `doom-switch-window-hook` only triggers if the created buffer is in a new window. 4. The use of `with-temp-buffer` in `centaur-tabs-line-format` counts as "buffer creation" in a "new window". 5. `+vc-gutter-update-h` is in `doom-switch-window-hook`. This refreshes git-gutter, which initiates a redraw of Emacs. 6. When Emacs redraws, it recalculates its mode and header lines. which triggers `doom-switch-window-hook` once, which triggers `+vc-gutter-update-h`, which redraws the screen, then Emacs recalculates the header line, running `centaur-tabs-line-format`... Infinite loop ensues Hopefully fixes: - hlissner/doom-emacs#2436 - ema2159/centaur-tabs#18 - ema2159/centaur-tabs#88
This commit is contained in:
parent
4830f9784f
commit
eb69073578
2 changed files with 8 additions and 4 deletions
|
@ -89,7 +89,8 @@ size.")
|
||||||
(unless (or doom-inhibit-switch-window-hooks
|
(unless (or doom-inhibit-switch-window-hooks
|
||||||
(eq doom--last-window (selected-window))
|
(eq doom--last-window (selected-window))
|
||||||
(minibufferp))
|
(minibufferp))
|
||||||
(let ((doom-inhibit-switch-window-hooks t))
|
(let ((doom-inhibit-switch-window-hooks t)
|
||||||
|
(inhibit-redisplay t))
|
||||||
(run-hooks 'doom-switch-window-hook)
|
(run-hooks 'doom-switch-window-hook)
|
||||||
(setq doom--last-window (selected-window))))))
|
(setq doom--last-window (selected-window))))))
|
||||||
|
|
||||||
|
@ -107,7 +108,8 @@ size.")
|
||||||
(eq (current-buffer) (get-buffer buffer-or-name))
|
(eq (current-buffer) (get-buffer buffer-or-name))
|
||||||
(and (eq orig-fn #'switch-to-buffer) (car args)))
|
(and (eq orig-fn #'switch-to-buffer) (car args)))
|
||||||
(apply orig-fn buffer-or-name args)
|
(apply orig-fn buffer-or-name args)
|
||||||
(let ((doom-inhibit-switch-buffer-hooks t))
|
(let ((doom-inhibit-switch-buffer-hooks t)
|
||||||
|
(inhibit-redisplay t))
|
||||||
(when-let (buffer (apply orig-fn buffer-or-name args))
|
(when-let (buffer (apply orig-fn buffer-or-name args))
|
||||||
(with-current-buffer (if (windowp buffer)
|
(with-current-buffer (if (windowp buffer)
|
||||||
(window-buffer buffer)
|
(window-buffer buffer)
|
||||||
|
@ -119,7 +121,8 @@ size.")
|
||||||
(let ((gc-cons-threshold most-positive-fixnum))
|
(let ((gc-cons-threshold most-positive-fixnum))
|
||||||
(if doom-inhibit-switch-buffer-hooks
|
(if doom-inhibit-switch-buffer-hooks
|
||||||
(apply orig-fn args)
|
(apply orig-fn args)
|
||||||
(let ((doom-inhibit-switch-buffer-hooks t))
|
(let ((doom-inhibit-switch-buffer-hooks t)
|
||||||
|
(inhibit-redisplay t))
|
||||||
(when-let (buffer (apply orig-fn args))
|
(when-let (buffer (apply orig-fn args))
|
||||||
(with-current-buffer buffer
|
(with-current-buffer buffer
|
||||||
(run-hooks 'doom-switch-buffer-hook))
|
(run-hooks 'doom-switch-buffer-hook))
|
||||||
|
|
|
@ -71,7 +71,8 @@ is deferred until the file is saved. Respects `git-gutter:disabled-modes'."
|
||||||
`doom-escape-hook' hooks."
|
`doom-escape-hook' hooks."
|
||||||
(when (and git-gutter-mode
|
(when (and git-gutter-mode
|
||||||
(not (memq this-command '(git-gutter:stage-hunk
|
(not (memq this-command '(git-gutter:stage-hunk
|
||||||
git-gutter:revert-hunk))))
|
git-gutter:revert-hunk)))
|
||||||
|
(not inhibit-redisplay))
|
||||||
(ignore (git-gutter)))))
|
(ignore (git-gutter)))))
|
||||||
;; update git-gutter when using magit commands
|
;; update git-gutter when using magit commands
|
||||||
(advice-add #'magit-stage-file :after #'+vc-gutter-update-h)
|
(advice-add #'magit-stage-file :after #'+vc-gutter-update-h)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue