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:
Henrik Lissner 2020-02-27 21:47:32 -05:00
parent 4830f9784f
commit eb69073578
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 8 additions and 4 deletions

View file

@ -71,7 +71,8 @@ is deferred until the file is saved. Respects `git-gutter:disabled-modes'."
`doom-escape-hook' hooks."
(when (and git-gutter-mode
(not (memq this-command '(git-gutter:stage-hunk
git-gutter:revert-hunk))))
git-gutter:revert-hunk)))
(not inhibit-redisplay))
(ignore (git-gutter)))))
;; update git-gutter when using magit commands
(advice-add #'magit-stage-file :after #'+vc-gutter-update-h)