emacs-lsp / lsp-ui

UI integrations for lsp-mode
https://emacs-lsp.github.io/lsp-ui
GNU General Public License v3.0
1.03k stars 141 forks source link

fit lsp-ui-imenu to longest line in buffer #764

Closed LemonBreezes closed 2 months ago

LemonBreezes commented 4 months ago

Previously, in buffers with many nested levels of imenu, the long lines would trail off past the width of the window. Now, we properly enlarge the window to fit the longest line.

LemonBreezes commented 2 months ago

Hello @jcs090218, when you get a chance, can you please review this PR? This PR fixes the window width not being adjusted to the size of the longest imenu entry. Before, imenu entries would trail off past the edge of the window and now they no longer do that for me.

jcs090218 commented 2 months ago

I don't know if this is a good design since there is a chance the imenu window will take up all the space. 🤔

LemonBreezes commented 2 months ago

I don't know if this is a good design since there is a chance the imenu window will take up all the space. 🤔

I mean, this only applies when the lsp-ui-imenu-window-width is 0. Basically, what I am saying is that the current behavior for auto-resizing the window to the buffer does not work.

LemonBreezes commented 2 months ago

fit-window-to-buffer does not actually use the longest line in the entire buffer. The documentation for it says: "The new width of WINDOW is calculated from the maximum length of its buffer's lines that follow the current start position of WINDOW." Somehow it doesn't work as intended for this case.

jcs090218 commented 2 months ago

It makes sense, then. Thank you!