-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
nvim_buf_set_lines
adjustment of cursor and of topline is inconsistent
#27720
Comments
It is/was not, and it cannot be true in general that this code does nothing to the buffer. It is a valid open question how it should scroll though. Just as with the other issue, a difference to 0.9.5 by itself does not prove a bug, but it shows a case where it can be discussed if the previous or the current behavior is the one we want moving forward. |
@bfredl Thank you for your response. I am glad to see that this issue has been caught on your radar. I understand that preserving the cursor position while rewriting the buffer content can be challenging. However, I believe it is important to maintain the previous behavior where the cursor position relative to the buffer and window remains the same. A common scenario is when reformatting a file, where the entire buffer is replaced with for example stylua's output. It is quite frustrating to have the cursor constantly moving with each format, making the editing experience very unpleasant. I have also encountered this issue with UI plugins, such as nui.nvim, where the cursor jumps when the tree is redrawn inside the buffer, even when the content has not changed. |
nvim_buf_set_lines
scrolls the buffer
@bfredl Could you please share with me what other behavior you are thinking could be a viable option? I cannot think of any other acceptable outcome and I think what I described should be the way |
The current one, which matches the actual semantics of set_lines replacing the entire range of lines with another range of lines. and then for neovim to provide some other mechanism for plugins to say that line numbers are at least "almost" preserved in this operation (i e it is fine to approximate old line numbers with new ones to keep the view almost the same in windows, current or not). The key point here is to relay the semantics of the operation, and |
@bfredl Please correct me if I'm misinterpreting but I'm not complaining about changes in line number. In fact, line number of cursor mostly stays same from before to after My issue is that the cursor position relative to the window changes after the operation. As you can see in the record, I start from the 6th line inside the window, but after running record.mp4 |
nvim_buf_set_lines
scrolls the buffernvim_buf_set_lines
scrolls the window
Does this make sense to you @bfredl ? |
yes, it is a bug that cursor position is not handled consistently like topline. I made the mistake of assuming that the title of the issue would describe the issue:) |
nvim_buf_set_lines
scrolls the windownvim_buf_set_lines
adjustment of cursor and of topline is inconsistent
Thanks for your reply @bfredl ! English is not my native language so forgive me about that :P Were you able to reproduce the issue? Do you have any rough estimate on when this can be fixed? |
yes, it will be fixed before 0.10 . |
@bfredl Thanks. Hope it gets fixed as soon as possible. FYI, this issue might be caused by the same core problem. |
A lot of functions in move.c only worked for curwin, alternatively took a `wp` arg but still only work if that happens to be curwin. Refactor those that are needed for update_topline(wp) to work for any window. fixes neovim#27723 fixes neovim#27720
A lot of functions in move.c only worked for curwin, alternatively took a `wp` arg but still only work if that happens to be curwin. Refactor those that are needed for update_topline(wp) to work for any window. fixes neovim#27723 fixes neovim#27720
A lot of functions in move.c only worked for curwin, alternatively took a `wp` arg but still only work if that happens to be curwin. Refactor those that are needed for update_topline(wp) to work for any window. fixes neovim#27723 fixes neovim#27720
A lot of functions in move.c only worked for curwin, alternatively took a `wp` arg but still only work if that happens to be curwin. Refactor those that are needed for update_topline(wp) to work for any window. fixes neovim#27723 fixes neovim#27720
A lot of functions in move.c only worked for curwin, alternatively took a `wp` arg but still only work if that happens to be curwin. Refactor those that are needed for update_topline(wp) to work for any window. fixes neovim#27723 fixes neovim#27720
A lot of functions in move.c only worked for curwin, alternatively took a `wp` arg but still only work if that happens to be curwin. Refactor those that are needed for update_topline(wp) to work for any window. fixes neovim#27723 fixes neovim#27720
A lot of functions in move.c only worked for curwin, alternatively took a `wp` arg but still only work if that happens to be curwin. Refactor those that are needed for update_topline(wp) to work for any window. fixes neovim#27723 fixes neovim#27720
A lot of functions in move.c only worked for curwin, alternatively took a `wp` arg but still only work if that happens to be curwin. Refactor those that are needed for update_topline(wp) to work for any window. fixes neovim#27723 fixes neovim#27720
A lot of functions in move.c only worked for curwin, alternatively took a `wp` arg but still only work if that happens to be curwin. Refactor those that are needed for update_topline(wp) to work for any window. fixes neovim#27723 fixes neovim#27720
A lot of functions in move.c only worked for curwin, alternatively took a `wp` arg but still only work if that happens to be curwin. Refactor those that are needed for update_topline(wp) to work for any window. fixes neovim#27723 fixes neovim#27720
A lot of functions in move.c only worked for curwin, alternatively took a `wp` arg but still only work if that happens to be curwin. Refactor those that are needed for update_topline(wp) to work for any window. fixes neovim#27723 fixes neovim#27720
A lot of functions in move.c only worked for curwin, alternatively took a `wp` arg but still only work if that happens to be curwin. Refactor those that are needed for update_topline(wp) to work for any window. fixes neovim#27723 fixes neovim#27720
Please try (very) latest master, just merged a fix. |
@bfredl Unfortunately, I don't think it is fixed. I've tried to detect the pattern of the behavior but I'm not really sure. Do you want me to open a new issue, or may I ask some maintainer reopen this thread? record.mp4 |
On top of that, I'm getting segfault crashes from commit This is not reproducible with Here is the stack trace (I masked some info). The most suspecious part IMO is this part. Hope this info helps, and please guide me what I should do if you need more information. I'm not very familiar with C but I'm more than happy to help. Program terminated with signal SIGSEGV, Segmentation fault.
#0 changed_window_setting (wp=0x0) at /home/------/.local/share/nvim-git/src/nvim/move.c:541
541 wp->w_lines_valid = 0; |
Is that the full stacktrace you got by typing |
@bfredl Amazing! Your branch However I'm still having a segfault issue with my own config as I reported above. Here is the full track trace. I managed to figure out how to get the full stack @zeertzjq :) I'm still not able to reproduce this with |
Looking at the bt, it looks like you have some plugin calling Looking at your plugins, it's probably nvim-ufo, which updated the signatures yesterday; you'll need to update it. |
@seandewar THANK YOU!! You saved my day! I can confirm that it was fixed by the latest commit in nvim-ufo (latest tag/release is too old tho). |
Problem
I believe the above code should do nothing to the buffer, but with the latest nightly, buffer is scrolled downwards resulting an inconsistent user experience.
I was not able to bisect the exact commit causing this problem, but I'm pretty sure this was caused by the series of refactoring #24889 done by @bfredl .
I found several similar issues, but they referred to the issue with some plugin or lsp.format, whereas my steps to reproduce is reproducible without any setup (nvim -u NONE).
Steps to reproduce
No config file required. (nvim -u NONE)
G
to go to the bottom.H
to move the cursor to the top of the window.Result
The buffer and cursor moves down and lands one line above the bottom
scrolloff
. The exact same behavior as doingzb
afterstep 3.
.Expected behavior
Do not scroll the buffer, and have no visual change in above case.
Neovim version (nvim -v)
NVIM v0.10.0-dev-2504+g3971797be1
Vim (not Nvim) behaves the same?
N/A
Operating system/version
Linux
Terminal name/version
Wezterm
$TERM environment variable
tmux-256color
Installation
Build from source
The text was updated successfully, but these errors were encountered: