diff options
author | Luuk van Baal <luukvbaal@gmail.com> | 2023-05-06 12:53:50 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2023-05-06 12:53:50 +0100 |
commit | b926bf47d61360a4ec5e4867714a08d70fd49965 (patch) | |
tree | 9517e3efd8bcf94d6d561e6f3f78a6f5a1a64258 | |
parent | c8502f9b880b6d23baa4f9d28b60e1ceb442e35f (diff) |
patch 9.0.1513: text scrolls unnecessarily when splittingv9.0.1513
Problem: Text scrolls unnecessarily when splitting and 'splitkeep' is not
"cursor".
Solution: Avoid resetting w_skipcol. (Luuk van Baal, closes #12334)
-rw-r--r-- | src/testdir/dumps/Test_splitkeep_skipcol_1.dump | 12 | ||||
-rw-r--r-- | src/testdir/test_window_cmd.vim | 17 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/window.c | 6 |
4 files changed, 36 insertions, 1 deletions
diff --git a/src/testdir/dumps/Test_splitkeep_skipcol_1.dump b/src/testdir/dumps/Test_splitkeep_skipcol_1.dump new file mode 100644 index 0000000000..c1414902b6 --- /dev/null +++ b/src/testdir/dumps/Test_splitkeep_skipcol_1.dump @@ -0,0 +1,12 @@ +|<+0#4040ff13#ffffff0@2|e+0#0000000&| |l|i|n|e| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |i|n| |o|n|e| |l|i|n|e| +|w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |i|n| |o|n|e| |l|i|n|e| |w|i|t|h| |l|o|t|s| +|o|f| |t|e|x|t| |i|n| |o|n|e| |l|i|n|e| @20 +|~+0#4040ff13&| @38 +|[+1#0000000&|N|o| |N|a|m|e|]| |[|+|]| @8|1|,|1|2|1| @9|A|l@1 +|<+0#4040ff13&@2|e+0#0000000&| |l|i|n|e| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |i|n| |o|n|e| |l|i|n|e| +>w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |i|n| |o|n|e| |l|i|n|e| |w|i|t|h| |l|o|t|s| +|o|f| |t|e|x|t| |i|n| |o|n|e| |l|i|n|e| @20 +|~+0#4040ff13&| @38 +|~| @38 +|[+3#0000000&|N|o| |N|a|m|e|]| |[|+|]| @8|1|,|1|2|1| @9|A|l@1 +| +0&&@39 diff --git a/src/testdir/test_window_cmd.vim b/src/testdir/test_window_cmd.vim index a3889de26a..549069080b 100644 --- a/src/testdir/test_window_cmd.vim +++ b/src/testdir/test_window_cmd.vim @@ -1935,6 +1935,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>" diff --git a/src/version.c b/src/version.c index 08f213a104..2665b0395f 100644 --- a/src/version.c +++ b/src/version.c @@ -696,6 +696,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1513, +/**/ 1512, /**/ 1511, diff --git a/src/window.c b/src/window.c index 244ee37d86..27b353e17c 100644 --- a/src/window.c +++ b/src/window.c @@ -1453,6 +1453,8 @@ win_init(win_T *newp, win_T *oldp, int flags UNUSED) 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 - WINBAR_HEIGHT(oldp); newp->w_prev_winrow = oldp->w_winrow + 2 * WINBAR_HEIGHT(oldp); @@ -6860,14 +6862,16 @@ win_new_height(win_T *wp, int height) } wp->w_height = height; - wp->w_skipcol = 0; wp->w_redr_status = TRUE; win_comp_scroll(wp); // There is no point in adjusting the scroll position when exiting. Some // values might be invalid. if (!exiting && *p_spk == 'c') + { + wp->w_skipcol = 0; scroll_to_fraction(wp, prev_height); + } } void |