Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Long paths #37

Open
goldfita opened this issue Nov 22, 2023 · 9 comments
Open

Long paths #37

goldfita opened this issue Nov 22, 2023 · 9 comments

Comments

@goldfita
Copy link

When the path length exceeds the posframe length, the files get cut off.

posframe_cursor_end_path

I'm unable to use the left/right arrow keys, but I can backup with M-b. Then it looks like this.

posframe_cursor_in_path

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.

posframe_not_centered

@cxa
Copy link

cxa commented Apr 14, 2024

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

@YueRen
Copy link

YueRen commented Oct 13, 2024

What issue is the workaround supposed to fix? It didn't fix the following problem for me:

  1. Do C-x C-f to be prompted to find file
  2. Write an filename so long that the path exceeds the width of the posframe and notice the width of the posframe increasing.
  3. Do C-g to abort find file
  4. Do another C-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)

@lucius-martius
Copy link

lucius-martius commented Oct 15, 2024

@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.

@YueRen
Copy link

YueRen commented Oct 17, 2024

@lucius-martius Thanks for the snippet! But I can't detect any change of behaviour, what is it supposed to affect?

@lucius-martius
Copy link

@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.

@YueRen
Copy link

YueRen commented Oct 17, 2024

@lucius-martius Nvm, I think I was confusing two different issues. That code works for me as well, thanks a lot for sharing!

tumashu added a commit that referenced this issue Oct 18, 2024
@tumashu
Copy link
Owner

tumashu commented Oct 18, 2024

Please try and test this commit: 17a21fe

@YueRen
Copy link

YueRen commented Oct 18, 2024

@tumashu works for me out of the box, thanks!!!

@tumashu
Copy link
Owner

tumashu commented Oct 18, 2024

OK, I will see other's feedback, if no problem, i will merge it.

Long path #49

tumashu added a commit that referenced this issue Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants