Merge pull request #23927 from zeertzjq/vim-9.0.1603

vim-patch:9.0.{1603,1610}: display wrong if scrolling multiple lines with 'smoothscroll'
This commit is contained in:
zeertzjq 2023-06-06 06:59:48 +08:00 committed by GitHub
commit 30e9ddfd05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 87 additions and 4 deletions

View File

@ -1344,7 +1344,7 @@ bool scrollup(long line_count, int byfold)
int width1 = curwin->w_width_inner - curwin_col_off(); int width1 = curwin->w_width_inner - curwin_col_off();
int width2 = width1 + curwin_col_off2(); int width2 = width1 + curwin_col_off2();
unsigned size = 0; unsigned size = 0;
linenr_T prev_topline = curwin->w_topline; const colnr_T prev_skipcol = curwin->w_skipcol;
if (do_sms) { if (do_sms) {
size = linetabsize(curwin, curwin->w_topline); size = linetabsize(curwin, curwin->w_topline);
@ -1396,8 +1396,9 @@ bool scrollup(long line_count, int byfold)
} }
} }
if (curwin->w_topline == prev_topline) { if (prev_skipcol > 0 || curwin->w_skipcol > 0) {
// need to redraw even though w_topline didn't change // need to redraw more, because wl_size of the (new) topline may
// now be invalid
redraw_later(curwin, UPD_NOT_VALID); redraw_later(curwin, UPD_NOT_VALID);
} }
} else { } else {

View File

@ -865,6 +865,62 @@ describe('smoothscroll', function()
]]) ]])
end) end)
-- oldtest: Test_smoothscroll_multi_skipcol()
it('scrolling mulitple lines and stopping at non-zero skipcol', function()
screen:try_resize(40, 10)
screen:set_default_attr_ids({
[0] = {foreground = Screen.colors.Blue, bold = true},
[1] = {background = Screen.colors.Grey90},
})
exec([[
setlocal cursorline scrolloff=0 smoothscroll
call setline(1, repeat([''], 8))
call setline(3, repeat('a', 50))
call setline(4, repeat('a', 50))
call setline(7, 'bbb')
call setline(8, 'ccc')
redraw
]])
screen:expect([[
{1:^ }|
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
aaaaaaaaaa |
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
aaaaaaaaaa |
|
|
bbb |
|
]])
feed('3<C-E>')
screen:expect([[
{0:<<<}{1:aaaaaa^a }|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
aaaaaaaaaa |
|
|
bbb |
ccc |
{0:~ }|
{0:~ }|
|
]])
feed('2<C-E>')
screen:expect([[
{0:<<<}{1:aaaaaa^a }|
|
|
bbb |
ccc |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
|
]])
end)
it("works with virt_lines above and below", function() it("works with virt_lines above and below", function()
screen:try_resize(55, 7) screen:try_resize(55, 7)
exec([=[ exec([=[

View File

@ -780,7 +780,7 @@ func Test_smoothscroll_incsearch()
call setline(14, 'bbbb') call setline(14, 'bbbb')
END END
call writefile(lines, 'XSmoothIncsearch', 'D') call writefile(lines, 'XSmoothIncsearch', 'D')
let buf = RunVimInTerminal('-S XSmoothIncsearch', #{rows: 8, cols:40}) let buf = RunVimInTerminal('-S XSmoothIncsearch', #{rows: 8, cols: 40})
call term_sendkeys(buf, "/b") call term_sendkeys(buf, "/b")
call VerifyScreenDump(buf, 'Test_smooth_incsearch_1', {}) call VerifyScreenDump(buf, 'Test_smooth_incsearch_1', {})
@ -795,4 +795,30 @@ func Test_smoothscroll_incsearch()
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
endfunc endfunc
" Test scrolling multiple lines and stopping at non-zero skipcol.
func Test_smoothscroll_multi_skipcol()
CheckScreendump
let lines =<< trim END
setlocal cursorline scrolloff=0 smoothscroll
call setline(1, repeat([''], 8))
call setline(3, repeat('a', 50))
call setline(4, repeat('a', 50))
call setline(7, 'bbb')
call setline(8, 'ccc')
redraw
END
call writefile(lines, 'XSmoothMultiSkipcol', 'D')
let buf = RunVimInTerminal('-S XSmoothMultiSkipcol', #{rows: 10, cols: 40})
call VerifyScreenDump(buf, 'Test_smooth_multi_skipcol_1', {})
call term_sendkeys(buf, "3\<C-E>")
call VerifyScreenDump(buf, 'Test_smooth_multi_skipcol_2', {})
call term_sendkeys(buf, "2\<C-E>")
call VerifyScreenDump(buf, 'Test_smooth_multi_skipcol_3', {})
call StopVimInTerminal(buf)
endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab