-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
feat(window/ui): add splitkeep option #19243
Conversation
BTW the motivation behind trying to merge it into core is that the "stabilization" done by the plugin is sometimes not fast enough in faster terminals. Thus resulting in flickering when restoring the topline. That and the overall gimmickyness of the plugin, never changing the scroll position at all is of course better than saving and restoring it. |
I'm not a neovim dev, but I have some immediate thoughts:
|
Definitely. I refrained from doing so as I was still looking for general feedback on the feasibility of the PR. The PR turned out to be easier than I imagined though so I guess I can draft the help docs.
Not sure about this either. I'm also wondering about the etiquette of opening PRs agains vim. I have no interest in doing so myself but I quickly checked and this part of core vim seems similar to nvim still. |
The etiquette is very much to contribute to Vim, if at all appropriate :) In this case, you are right that this PR is directly applicable to Vim. The best course of action is then indeed to first make the PR to Vim, see what they think, and if they merge it, port that patch. This way both projects profit from the new feature, and we avoid needless divergence in case Vim decides on slight changes to, say, the abbreviated option name. (If Vim rejects the feature, we can reopen this PR, now with the knowledge that we don't need to take upstream into account.) |
I guess I'll do that then. |
e44f2d4
to
6534eea
Compare
Adding a screen test is easy, see test/functional/example_spec.lua for example. You can run the test like this:
I didn't find an existing test file where this would obviously fit, but maybe one of these:
else we might need a new file, |
Are you sure we would want this as default? Isn't the point of the scrolling to ensure the split doesn't cover the last position of the cursor? |
The current I would expect 'splitscroll=false' to scroll if the cursor position would be hidden, since there is not yet an internal concept of a window with an off-screen cursor. This PR needs tests for both cases in any case. (btw, does this imply we need a number or flags option instead of a boolean? because there are several possible behaviors.) |
Hmm, sounds like the current behaviour is naive/simple and now we just want to make it "smart". I'd contemplate not even making an option for this and just change the current behaviour, unless there's a good argument I'm not realising.
Can you list these? Also note we need to make sure we always respect |
Is this PR not just allowing currently existing "smart" behavior to be disabled? |
Yes this makes sense, the option was also available in the plugin. There it was named |
|
Even when the cursor would not be hidden behind the split, currently scrolling happens just to "keep the same relative position". To me this is unnecessary but I guess it could be up to personal preference. Hence the option, but perhaps not necessary if we think the current default is undesired. |
Keeping the relative position is a valid use-case. Could avoid a new option by changing the core behavior, then users who want "keep relative position" could use a But that doesn't resolve the question about letting the cursor row get hidden: that does not seem like a good default behavior, and raises a lot of questions. If we are going to entertain the idea of letting the cursor row get hidden, that would need to be a third choice. |
I thought it could look something like the latest commit. Perhaps the solution is too naive though, I never use |
Vim upstream will consider the feature if we can agree on what it will do. They will require a test as well, |
Yes |
Ok, let's just introduce an option.
I'm working on the assumption that any new behaviour we add, doesn't break In terms of how we do it, I think we should just add
We need to check if the cursor will remain in the window and obeys |
I don't see any harm in adding the third option for those who prefer it. It was the default for my plugin, and never got any complaints. I agree that the cursor position should never violate
Yeah I considered this too and I agree it would probably be better behavior but I wasn't sure it would be worth the hassle. |
I think I'll stop updating this PR until some movement happens in vim/vim#10682. Furthermore it seems like we still haven't agreed on what the option should be so perhaps updating either PR is futile but I thought I would cross post https://github.com/vim/vim/pull/10682/files#r917474316 to see if there's any feedback here. |
Any particular reason this was moved to the 0.9 milestone btw @clason? Is it too late in the 0.8 cycle? Is anything else needed for this PR? I can keep updating it with patches as vim bug reports/improvements keep coming in but 0.9 seems far away. |
Yes, it's (much) too late; we've been in feature freeze for a week already. |
b2d4b05
to
520708b
Compare
Whoops, totally missed that. Haven't really kept up with neovim development while working on the vim patch😅 Cross posting from vim/vim#10682 (comment):
So yeah circling back to this after some initial user bug reports/improvements to the feature, I really do think providing this option is as simple as guarding the To reiterate, instead of having the previously proposed options for scroll behavior depending on whether or not the cursor would be valid ({"normal", "noscroll", "neverscroll"}, we dropped this because changing the cursor position was considered not to be that egregious when splitting a window, and as a compromise we add the previous cursor position to the jumplist). Now the proposal is the have 3 separate scroll behaviors for 'splitscroll' because user(s)(@ychin) might prefer one over the other:
Not sure "counterscroll" is very telling, can anyone think of a better name for these option values? Do any more users see the need for the third option? See vim/vim#11258 for the proposal. |
b119175
to
f581406
Compare
src/nvim/testdir/test_window_cmd.vim
Outdated
let &laststatus = (run % 3) | ||
let &splitbelow = (run % 3) | ||
let &equalalways = (run % 2) | ||
"let wsb = (run % 2) && &splitbelow |
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.
Is this because in Vim the splitted window does not have a winbar, while in Nvim it does?
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.
Oh yes. I just noticed that this variable used to be called winbar_sb
.
vim-patch:9.0.0445: when opening/closing window text moves up/down Problem: When opening/closing window text moves up/down. Solution: Add the 'splitscroll' option. When off text will keep its position as much as possible. vim/vim@29ab524 vim-patch:9.0.0455: a few problems with 'splitscroll' Problem: A few problems with 'splitscroll'. Solution: Fix 'splitscroll' problems. (Luuk van Baal, closes vim/vim#11117) vim/vim@5ed3917 vim-patch:9.0.0461: 'scroll' is not always updated Problem: 'scroll' is not always updated. Solution: Call win_init_size() at the right place. vim/vim@470a141 vim-patch:9.0.0465: cursor moves when cmdwin is closed when 'splitscroll' is off Problem: Cursor moves when cmdwin is closed when 'splitscroll' is off. Solution: Temporarily set 'splitscroll' when jumping back to the original window. (closes vim/vim#11128) vim/vim@e697d48 vim-patch:9.0.0469: cursor moves if cmdwin is closed when 'splitscroll' is off Problem: Cursor moves if cmdwin is closed when 'splitscroll' is off. Solution: Skip win_fix_cursor if called when cmdwin is open or closing. (Luuk van Baal, closes vim/vim#11134) vim/vim@3735f11 vim-patch:9.0.0478: test for 'splitscroll' takes too much time Problem: Test for 'splitscroll' takes too much time. Solution: Only test some of the combinations. (Luuk van Baal, closes vim/vim#11139) vim/vim@594f9e0 vim-patch:9.0.0486: text scrolled with 'nosplitscroll', autocmd win and help Problem: Text scrolled with 'nosplitscroll', autocmd win opened and help window closed. Solution: Skip win_fix_scroll() in more situations. (Luuk van Baal, closes vim/vim#11150) vim/vim@d5bc762 vim-patch:9.0.0505: various problems with 'nosplitscroll' Problem: Various problems with 'nosplitscroll'. Solution: Fix 'nosplitscroll' problems. (Luuk van Baal, closes vim/vim#11166) vim/vim@faf1d41 vim-patch:9.0.0555: scrolling with 'nosplitscroll' in callback changing curwin Problem: Scrolling with 'nosplitscroll' in callback changing curwin. Solution: Invalidate w_cline_row in the right place. (Luuk van Baal, closes vim/vim#11185) vim/vim@20e5856 vim-patch:9.0.0603: with 'nosplitscroll' folds are not handled correctly Problem: With 'nosplitscroll' folds are not handled correctly. Solution: Take care of closed folds when moving the cursor. (Luuk van Baal, closes vim/vim#11234) vim/vim@7c1cbb6 vim-patch:9.0.0605: dump file missing Problem: Dump file missing. Solution: Add the missing dump file. (issue vim/vim#11234) vim/vim@439a2ba vim-patch:9.0.0647: the 'splitscroll' option is not a good name Problem: The 'splitscroll' option is not a good name. Solution: Rename 'splitscroll' to 'splitkeep' and make it a string option, also supporting "topline". (Luuk van Baal, closes vim/vim#11258) vim/vim@13ece2a vim-patch:9.0.0667: ml_get error when 'splitkeep' is "screen" Problem: ml_get error when 'splitkeep' is "screen". (Marius Gedminas) Solution: Check the botline is not too large. (Luuk van Baal, closes vim/vim#11293, closes vim/vim#11292) vim/vim@346823d
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.
LGTM. I pushed a fixup commit with some small changes.
Yay! I see I missed some of my own (style) changes from the vim patches. So thanks for the fixup and merge! |
This comment was marked as off-topic.
This comment was marked as off-topic.
Unfortunately maintainers weren't able to review this before the 0.8 release. I would be willing to make a backport PR but AFAIK 0.x.y releases are only for bug fixes. |
Hi, I'm the author of a relatively popular plugin. I'm looking for feedback on whether something like this PR has any possibility of being merged with the behavior of said plugin being provided in core behind a new option.
I had originally assumed while writing the plugin that the "jarring" phenomenon of window viewports changing(scrolling), when splitting windows horizontally, was some undesired side effect of managing the windows. Now, having finally taken the time to look into the source code, it seems this is done intentionally with the following justification:
neovim/src/nvim/window.c
Lines 6193 to 6194 in 41785b1
After 2 months of work on the vim patch it was finally merged. This PR now ports vim/vim@29ab524, vim/vim@5ed3917, vim/vim@470a141, vim/vim@3735f11, vim/vim@594f9e0, vim/vim@d5bc762, vim/vim@faf1d41, vim/vim@20e5856, vim/vim@7c1cbb6, vim/vim@439a2ba, vim/vim@13ece2a, vim/vim@346823d.