Open goldfita opened 1 year ago
You can use my workaround:
(advice-add 'vertico-posframe--show
:before
(defun vertico-posframe--show/before (&rest _args)
;; https://github.com/minad/vertico/blob/0f12d85a5a38353471d7657572e69f00fa1b9639/vertico.el#L611
(setq vertico-posframe-truncate-lines
(< (point) (* 0.8 (window-width (active-minibuffer-window)))))))
What issue is the workaround supposed to fix? It didn't fix the following problem for me:
C-x C-f
to be prompted to find fileC-g
to abort find fileC-x C-f
and notice that the posframe is glitched out.(Note: You can replace C-x C-f
with anything that invokes a posframe, for example M-x
)
@YueRen I use this workaround instead:
(defun vertico-posframe-set-auto-hscroll-current-line ()
(when (bound-and-true-p vertico--input)
(let ((inhibit-message t))
(setq-local auto-hscroll-mode 'current-line))))
(add-hook 'minibuffer-setup-hook 'vertico-posframe-set-auto-hscroll-current-line)
You may need to make it more complex if you use things like vertico-multiform, since this affects all vertico minibuffers, not just vertico-posframe ones.
@lucius-martius Thanks for the snippet! But I can't detect any change of behaviour, what is it supposed to affect?
@YueRen It's supposed to enable the vertical scrolling only for the long line (i.e. auto-hscroll-mode), leaving the other lines scrolled to the beginning of the line.
In a vertico buffer with vertico-posframe this means that when you enter a long path at the top it should only shift the prompt line to the right, not the result lines. @cxa's solution on the other hand is supposed to break the line before it would scroll the whole buffer right, but that never worked for me.
My snippet might not work immediately, since a vertico buffer might already exist. You might need to either kill the vertico buffer or restart emacs with the snippet in your config.
If it still doesn't work, I have no idea. Maybe bisect your Vertico(-posframe) config or other packages that affect it. It definitely works for me. I can easily reproduce the issue with my snippet commented out and it's completely fixed when I enable it again.
@lucius-martius Nvm, I think I was confusing two different issues. That code works for me as well, thanks a lot for sharing!
Please try and test this commit: https://github.com/tumashu/vertico-posframe/commit/17a21feb1f7ca415665e18360f89e995d3a2c4bd
@tumashu works for me out of the box, thanks!!!
OK, I will see other's feedback, if no problem, i will merge it.
When the path length exceeds the posframe length, the files get cut off.
I'm unable to use the left/right arrow keys, but I can backup with
M-b
. Then it looks like this.Also, I noticed a couple other quirks. When the path is too long, the posframe width changes. Also, when you shrink the emacs frame, hit tab, then maximize, the posframe gets moved. You can hit tab again to recenter.