-
Notifications
You must be signed in to change notification settings - Fork 238
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
fix(renderer): fix jumping to the top when opening files. #1274
fix(renderer): fix jumping to the top when opening files. #1274
Conversation
When opening files that you had to scroll down to find, the neo-tree window jumped to the top. This is because Neovim changed the way `nvim_buf_set_lines` works. To make sure the window stays fixed, we have to use `winsaveview` and `winrestview`.
Please @miversen33 can you try it and see if I made a mess? |
I have a fix for #996 that builds on top of this PR. I'll have my commit cleaned up and I'll test a few edge cases and I'll update this PR |
8473670
to
0acea00
Compare
I'll pull this down and review the branch and code this evening, I have a nice long drive ahead of me this afternoon |
We can use `lnum` from winsaveview to set our cursor and not depend on M.follow_focus and state.tree.get_node (which can be nil sometimes). This way we don't trigger M.follow_focus window centering algorithm when expanding or closing nodes.
0acea00
to
6cf6f37
Compare
I left some notes on this. The overall gist seems good though I will not be the one to sign off on this. I will leave that to either @pysan3 or @cseickel as they are far more active in neo-tree core than myself. They will in theory be able to see potential side effects from this code that I might miss. |
The change looks awesome on my end! Thanks a lot! I'll pass it to @cseickel now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable to me and since @miversen33 and @pysan3 also reviewed I'll skip testing it myself.
Thanks!
Sorry for mentioning that this pr seems breaking the Open one file and run After running |
That is true. Beyond that, any action you take will result in the previously revealed file being focused. That includes opening other files. Whatever the last revealed file is will be permanently stuck and refocused after every render. I will make this a new issue. |
When opening files you had to scroll down to find, the neo-tree window jumped to the top (see #1025).
This is because Neovim changed the way
nvim_buf_set_lines
works in neovim/neovim@0081549 (neovim/neovim#24824) and later in neovim/neovim#24889This change in Neovim caused some problems in plugins:
To ensure the window stays fixed, we have to use
winsaveview
andwinrestview
(wrapped inM.position
) insiderender_tree
.Fixes #1025
Fixes #996