diff options
author | Luuk van Baal <luukvbaal@gmail.com> | 2023-05-06 19:24:45 +0200 |
---|---|---|
committer | Luuk van Baal <luukvbaal@gmail.com> | 2023-05-07 00:38:45 +0200 |
commit | 8e74569d7ee170b8661bdc74d61cf6be95303060 (patch) | |
tree | 024921e7f0be9c6779d9e3da28b23a1e16fcfae0 | |
parent | 3b2bd8d69e6c0a173562778fae6ece67d9adf52c (diff) | |
download | rneovim-8e74569d7ee170b8661bdc74d61cf6be95303060.tar.gz rneovim-8e74569d7ee170b8661bdc74d61cf6be95303060.tar.bz2 rneovim-8e74569d7ee170b8661bdc74d61cf6be95303060.zip |
vim-patch:9.0.1513: text scrolls unnecessarily when splitting
Problem: Text scrolls unnecessarily when splitting and 'splitkeep' is not
"cursor".
Solution: Avoid resetting w_skipcol. (Luuk van Baal, closes vim/vim#12334)
https://github.com/vim/vim/commit/b926bf47d61360a4ec5e4867714a08d70fd49965
-rw-r--r-- | src/nvim/window.c | 5 | ||||
-rw-r--r-- | test/functional/legacy/window_cmd_spec.lua | 25 | ||||
-rw-r--r-- | test/old/testdir/test_window_cmd.vim | 17 |
3 files changed, 46 insertions, 1 deletions
diff --git a/src/nvim/window.c b/src/nvim/window.c index a15be27f74..fd6755a382 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -1616,6 +1616,9 @@ static void win_init(win_T *newp, win_T *oldp, int flags) ? NULL : xstrdup(oldp->w_prevdir); if (*p_spk != 'c') { + if (*p_spk == 't') { + newp->w_skipcol = oldp->w_skipcol; + } newp->w_botline = oldp->w_botline; newp->w_prev_height = oldp->w_height; newp->w_prev_winrow = oldp->w_winrow; @@ -6605,13 +6608,13 @@ void win_set_inner_size(win_T *wp, bool valid_cursor) set_fraction(wp); } } - wp->w_skipcol = 0; wp->w_height_inner = height; win_comp_scroll(wp); // There is no point in adjusting the scroll position when exiting. Some // values might be invalid. if (valid_cursor && !exiting && *p_spk == 'c') { + wp->w_skipcol = 0; scroll_to_fraction(wp, prev_height); } redraw_later(wp, UPD_SOME_VALID); diff --git a/test/functional/legacy/window_cmd_spec.lua b/test/functional/legacy/window_cmd_spec.lua index 3a51f7a23f..373a9c7163 100644 --- a/test/functional/legacy/window_cmd_spec.lua +++ b/test/functional/legacy/window_cmd_spec.lua @@ -254,4 +254,29 @@ describe('splitkeep', function() | ]]) end) + + -- oldtest: Test_splitkeep_skipcol() + it('skipcol is not reset unnecessarily and is copied to new window', function() + screen:try_resize(40, 12) + exec([[ + set splitkeep=topline smoothscroll splitbelow scrolloff=0 + call setline(1, 'with lots of text in one line '->repeat(6)) + norm 2 + wincmd s + ]]) + screen:expect([[ + <<<e line with lots of text in one line | + with lots of text in one line with lots | + of text in one line | + ~ | + [No Name] [+] | + <<<e line with lots of text in one line | + ^with lots of text in one line with lots | + of text in one line | + ~ | + ~ | + [No Name] [+] | + | + ]]) + end) end) diff --git a/test/old/testdir/test_window_cmd.vim b/test/old/testdir/test_window_cmd.vim index f18d1719c0..d4ff241366 100644 --- a/test/old/testdir/test_window_cmd.vim +++ b/test/old/testdir/test_window_cmd.vim @@ -1879,6 +1879,23 @@ func Test_splitkeep_status() call StopVimInTerminal(buf) endfunc +" skipcol is not reset unnecessarily and is copied to new window +func Test_splitkeep_skipcol() + CheckScreendump + + let lines =<< trim END + set splitkeep=topline smoothscroll splitbelow scrolloff=0 + call setline(1, 'with lots of text in one line '->repeat(6)) + norm 2 + wincmd s + END + + call writefile(lines, 'XTestSplitkeepSkipcol', 'D') + let buf = RunVimInTerminal('-S XTestSplitkeepSkipcol', #{rows: 12, cols: 40}) + + call VerifyScreenDump(buf, 'Test_splitkeep_skipcol_1', {}) +endfunc + func Test_new_help_window_on_error() help change.txt execute "normal! /CTRL-@\<CR>" |