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)

b926bf47d6
This commit is contained in:
Luuk van Baal 2023-05-06 19:24:45 +02:00
parent 3b2bd8d69e
commit 8e74569d7e
3 changed files with 46 additions and 1 deletions

View File

@ -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);

View File

@ -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)

View File

@ -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>"