dirvish
dirvish copied to clipboard
[Bug] dirvish-side window not restored correctly after exiting minibuffer
Thank you for the bug report
- [X] I am using the latest version of
dirvish
related packages. - [X] I checked CUSTOMIZING|EXTENSIONS.
- [ ] You may also try reproduce the issue using clean environment and minimal configurations with
the command
emacs -Q
.
Bug description
After exiting the minibuffer, the dirvish-side
buffer moves to a new window, while the sidebar window switches to *Dirvish-temp*
instead.
Steps to reproduce
- Call
dirvish-side
to open the sidebar. - With the sidebar window selected, call any command which focuses the minibuffer. A simple
M-x
works. - Exit the minibuffer by finishing your command or cancelling it with
C-g
.
If the sidebar window is merely open (but not selected) when the minibuffer is focused, the issue does not occur.
Expected behavior
I expect the window configuration to be the same before and after focusing the minibuffer.
OS
Linux
Emacs Version
28
Emacs Configurations
https://gitlab.com/ajgrf/dotfiles
Error callstack
No response
Anything else
asciinema recording of the issue.
Seems to have something to do with switch-to-buffer-obey-display-actions
. When I set it to nil (the default), the issue goes away. I'd much rather find a proper fix than have to change that variable, though.
I spent some time trying to debug this, but in the end I decided to just unset switch-to-buffer-obey-display-actions
and rewrite the parts of my config that depended on it. Feel free to close this issue if you want.
I ran into the same thing just now, will search for a somewhat proper fix as setting switch-to-buffer-obey-display-actions
is not an option.
(defun dirvish-side-obey-display-actions (original-function &rest original-arguments)
(let ((switch-to-buffer-obey-display-actions nil))
(message "test")
(apply original-function original-arguments)))
(advice-add 'dirvish-side :around #'dirvish-side-obey-display-actions)
I tried that, but it doesn't really work, interestingly it works if I (debug-on-variable-change 'switch-to-buffer-obey-display-actions)
I found a very awful, but working, fix
(defun dirvish-side-buffer-p (buffer-or-name)
"Return t if BUFFER-OR-NAME is a dirvish buffer and a side buffer."
(with-current-buffer buffer-or-name
(let ((dv (dirvish-curr)))
(if (and dv (member 'side (dv-type dv)))
t
nil))))
(defun dirvish-ignore-display-buffer (original-function buffer-or-name &rest original-arguments)
(let ((switch-to-buffer-obey-display-actions (not (dirvish-side-buffer-p buffer-or-name))))
(apply original-function buffer-or-name original-arguments)))
(advice-add 'switch-to-buffer :around #'dirvish-ignore-display-buffer)
@alexluigit any suggestions here? @MagicRB's fix breaks other things for me, but this bug is also annoying