Skip to content

auto_expand_width gets caught in infinite loop and hangs neovim #624

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

Closed
cseickel opened this issue Nov 26, 2022 · 8 comments
Closed

auto_expand_width gets caught in infinite loop and hangs neovim #624

cseickel opened this issue Nov 26, 2022 · 8 comments
Labels
bug Something isn't working

Comments

@cseickel
Copy link
Contributor

I've noticed that with window.auto_expand_width enabled, sometimes neovim will freeze when I open neo-tree as a sidebar. I njust tailed the logs when this happened and saw this scrolling by:
image

Related to #580
@pysan3 Can you take a look at this?

@cseickel cseickel added the bug Something isn't working label Nov 26, 2022
@pysan3
Copy link
Collaborator

pysan3 commented Nov 26, 2022

Hi, I don't have a pc with me right now so I can't test it right now but it seems that the estimated length of the expanded width is too big that it cannot fit the nvim window.

When there is not enough width for the expanded width, it tries to expand more indefinitely falling into an infinite loop which is causing the nvim to freeze.

I see that the estimated width is over 10,000 but did you purposely put a very very long file name?
Or maybe expanding a recursive directory symlink might explain this problem?

Could you give me a screenshot shot of the sidepanel when setting it off but with a quite big window.width in the first place?

@pysan3
Copy link
Collaborator

pysan3 commented Nov 26, 2022

Oh, the estimated width increments one by one.

This might be a bug in estimating the required width of the resulting panel.

Could you send me your whole neo-tree configuration because I didn't face this issue with my setup?

@cseickel
Copy link
Contributor Author

I see that the estimated width is over 10,000 but did you purposely put a very very long file name?
Or maybe expanding a recursive directory symlink might explain this problem?

This is just a standard set of files, nothing particularly long and it shouldn't be opening folders recursively. Here is my current config: https://github.com/cseickel/dotfiles/blob/e4189bff222470ad07eeb9c947b4cbc4848b6a86/config/nvim/lua/plugins/config/neo-tree.lua#L2-L294

@pysan3
Copy link
Collaborator

pysan3 commented Nov 26, 2022

Thanks.

One thing I'm concerned is that the width required is not aligned with the strwidth of the content, and I had to add 1 in order to align with what is shown in the window.
Here

Can you guess where this 1 is coming from, and is this actually calculating the width of the window accurately?

EDIT:
I got to my pc but could not replicate the problem...

@pysan3
Copy link
Collaborator

pysan3 commented Nov 26, 2022

When there is not enough width for the expanded width, it tries to expand more indefinitely falling into an infinite loop which is causing the nvim to freeze.

Do you know any vim.api.xxx or something that tells the maximum window width available in current terminal?
If there's any, changing this line could solve the problem.
huge_number

- local huge_number = 2000
+ local huge_number = vim.api.nvim_give_me_the_maximum_possible_window_width(0)

@cseickel
Copy link
Contributor Author

I think that would be vim.o.columns

@pysan3

This comment was marked as outdated.

@pysan3
Copy link
Collaborator

pysan3 commented Nov 26, 2022

One thing I'm concerned is that the width required is not aligned with the strwidth of the content, and I had to add 1 in order to align with what is shown in the window.
Here

Can you guess where this 1 is coming from, and is this actually calculating the width of the window accurately?

Ok, so it seems that this + 1 is what is causing problem on your case.
I think I got something wrong somewhere not related to this plugin so let's remove this + 1 for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants