-
Notifications
You must be signed in to change notification settings - Fork 241
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 cursor jumping #1377
Conversation
@cseickel I couldn't understand why you had Do you remember what that number was for? |
I think that I used |
@pysan3 I'm a little short on time but I'll try to test this out and review in this next 24 hours. |
Thanks a lot <3 |
@pysan3 excuse me to write comment on this pr. thanks for pointing it out to me. but i think my problem which in #1310 (comment) is closed by |
@rizkyilhampra I really can't reproduce your issue anymore. Could you send me a screen record? |
Pulled your branch, will report back as soon as possible. Thank you! |
Yikes, I didn't pull the latest main branch into this branch. This branch didn't have the fix included. Merged this branch to the latest main branch so please test it out again @MunifTanjim @teocns . Thanks for your reply @rizkyilhampra, indeed this branch shouldn't have worked for you lol. |
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 good to me. Thanks for taking care of this!
@cseickel Looks like some amount of people are waiting for this fix. What do you think of making a new tag release? |
Released as 3.19 |
Originated from: #1374
Discussion
I reported this before, but it's not completely fixed: #996
I tracked it down to this piece of codes:
neo-tree.nvim/lua/neo-tree/ui/renderer.lua
Lines 542 to 547 in 459c603
If I comment it out, everything works perfectly as expected.
Anybody knows what that piece of code does?
neo-tree.nvim/lua/neo-tree/ui/renderer.lua
Line 542 in 459c603
This moves the current node at the bottom of screen.
neo-tree.nvim/lua/neo-tree/ui/renderer.lua
Line 546 in 459c603
Then this moves another line at the top of screen.
These causes unnecessary jumps and it's very problematic.
Originally posted by @MunifTanjim in #1374
zb
moves your cursor to the bottom of the window, respectingscrolloff
<line>zt
moves the cursor to the indicated line and sets that line as the top of the window, respectingscrolloff
Why?
This chunk of code is not about saving the top line at all, it is the opposite. It moves the top line if either of these situations occur:
Fixing the scrolled down to far problem is mostly about opening and closing folders which change the overall size of the tree and can lead to be scrolled down when you don't need to be.
The "requested extra padding" is for the sake of the search popup which floats over top of the bottom of the window. You need the extra padding to ensure that the focused node is not under the floating window.
How?
Given that understanding, I will attempt to walk through the code.
expected_bottom_line
is where we want the focused node to be if it can't be visible by scrolling the window all the way to the top, which is the ideal goal.expected_bottom_line
is off of the screen, then:normal! zb
move the current focused line to the bottom of the window, preserving the user'sscrolloff
setting.scrolloff
. Why? I have no idea. Maybe everything afternormal! zb
should be removed.I could have misinterpreted, even though I think I did write this code.
Originally posted by @cseickel in #1374 (comment)
If I'm not mistake, all these are needed when
neo-tree
needs to reveal the file for current buffer in the tree, right?What about the case when a node is manually being collapsed? That's when the weird jump occurs. Here's a recording:
If I comment out those codes, it works as expected:
Originally posted by @MunifTanjim in #1374 (reply in thread)
OK, I've looked into the code and here's the problem.
expected_bottom_line
should actually be the most bottom line cursor can be in order to not conflict withbottom_scroll_padding
(ie search bar height).Current code forces cursor position to be on this line, even when there are actually more content below the cursor to spare and there were no reason to be afraid of
bottom_scroll_padding
.normal! zb
and other code are necessary when the tree had more height than the window and the last line was below window's bottom line, but after closing the node, the buffer length shrunk and last line is now visible. Neotree will scroll down a bit so that there are no blank lines below the tree.Originally posted by @pysan3 in #1374 (reply in thread)
Working nicely for me so far 🚀
Originally posted by @MunifTanjim in #1374 (reply in thread)
Reproduce
Here's how I reproduced it with the linux kernel.
:Neotree reveal_file=drivers/gpu/drm/nouveau/include/nvrm/535.113.01/common/sdk/nvidia/inc/ctrl/ctrl2080/ctrl2080internal.h
zz
).close_node
ctrl2080/
but the window scrolled downwards as ifzb
(where I don't want the buffer to move).Originally posted by @pysan3 in #1374 (reply in thread)
Mentions
I'd be more than happy if you could test this fix.
cc @cseickel @rizkyilhampra @teocns