From 13b64229a01c8dae74177299147156b7ac85094d Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 7 Apr 2025 13:43:00 -0400 Subject: [PATCH] fix(popup): fringe/margins adjusted in wrong window Due to a race condition in some contexts, hooks that adjusted window fringes or margins weren't targeting the windows (usually popups) they were supposed to, often affecting the last selected window instead. This could cause the fringes (or margins) to resize or outright vanish unexpectedly in the wrong windows (e.g. after opening or killing a vterm or eshell popup). Fix: #8346 --- modules/term/eshell/autoload/eshell.el | 2 ++ modules/term/eshell/config.el | 3 --- modules/ui/popup/autoload/popup.el | 7 ++++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/term/eshell/autoload/eshell.el b/modules/term/eshell/autoload/eshell.el index 5b95c761a..198b18269 100644 --- a/modules/term/eshell/autoload/eshell.el +++ b/modules/term/eshell/autoload/eshell.el @@ -120,6 +120,8 @@ (if (eq major-mode 'eshell-mode) (run-hooks 'eshell-mode-hook) (eshell-mode)) + (set-window-fringes nil 0 0) + (set-window-margins nil 1 nil) (when command (+eshell-run-command command buf))) buf)) diff --git a/modules/term/eshell/config.el b/modules/term/eshell/config.el index 9cabb61b1..42c9650e5 100644 --- a/modules/term/eshell/config.el +++ b/modules/term/eshell/config.el @@ -92,9 +92,6 @@ You should use `set-eshell-alias!' to change this.") ;; UI enhancements (add-hook! 'eshell-mode-hook - (defun +eshell-remove-fringes-h () - (set-window-fringes nil 0 0) - (set-window-margins nil 1 nil)) (defun +eshell-enable-text-wrapping-h () (visual-line-mode +1) (set-display-table-slot standard-display-table 0 ?\ ))) diff --git a/modules/ui/popup/autoload/popup.el b/modules/ui/popup/autoload/popup.el index 278255630..0c5679706 100644 --- a/modules/ui/popup/autoload/popup.el +++ b/modules/ui/popup/autoload/popup.el @@ -256,14 +256,15 @@ Uses `shrink-window-if-larger-than-buffer'." (defun +popup-adjust-fringes-h () "Hides the fringe in popup windows, restoring them if `+popup-buffer-mode' is disabled." - (let ((f (if (bound-and-true-p +popup-buffer-mode) 0))) - (set-window-fringes nil f f fringes-outside-margins))) + (when (+popup-window-p) + (let ((f (if (bound-and-true-p +popup-buffer-mode) 0))) + (set-window-fringes nil f f fringes-outside-margins)))) ;;;###autoload (defun +popup-adjust-margins-h () "Creates padding for the popup window determined by `+popup-margin-width', restoring it if `+popup-buffer-mode' is disabled." - (when +popup-margin-width + (when (and +popup-margin-width (+popup-window-p)) (unless (memq (window-parameter nil 'window-side) '(left right)) (let ((m (if (bound-and-true-p +popup-buffer-mode) +popup-margin-width))) (set-window-margins nil m m)))))