Check buffer is active before modifying margins

Without checking this, as well as doing extra work this had the
undesirable side-effect of focusing non-active buffers.
This commit is contained in:
TEC 2022-07-29 02:21:56 +08:00
parent 34df3ef1b0
commit 66ab07fce9
Signed by: tec
GPG Key ID: 779591AFDB81F06C
1 changed files with 3 additions and 1 deletions

View File

@ -5340,7 +5340,9 @@ numbers is stripped away.
"The `left-margin-width' to be used in `text-mode' buffers.")
(defun +setup-text-mode-left-margin ()
(when (derived-mode-p 'text-mode)
(when (and (derived-mode-p 'text-mode)
(eq (current-buffer) ; Check current buffer is active.
(window-buffer (frame-selected-window))))
(setq left-margin-width (if display-line-numbers
0 +text-mode-left-margin-width))
(set-window-buffer (get-buffer-window (current-buffer))