dirvish icon indicating copy to clipboard operation
dirvish copied to clipboard

[Bug] dirvish-side window not restored correctly after exiting minibuffer

Open axgfn opened this issue 2 years ago • 7 comments

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

  1. Call dirvish-side to open the sidebar.
  2. With the sidebar window selected, call any command which focuses the minibuffer. A simple M-x works.
  3. 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.

axgfn avatar Feb 22 '23 02:02 axgfn

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.

axgfn avatar Feb 22 '23 07:02 axgfn

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.

axgfn avatar May 10 '23 23:05 axgfn

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.

MagicRB avatar Jun 11 '23 10:06 MagicRB

  (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)

MagicRB avatar Jun 11 '23 10:06 MagicRB

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)

MagicRB avatar Jun 15 '23 17:06 MagicRB

@alexluigit any suggestions here? @MagicRB's fix breaks other things for me, but this bug is also annoying

indigoviolet avatar Sep 22 '23 00:09 indigoviolet