patch 9.2.1234: 'smoothscroll' not working with wrapped lines and vir… · vim/vim@ec0d714 · GitHub
Skip to content

Commit ec0d714

Browse files
Yamagichrisbra
authored andcommitted
patch 9.2.1234: 'smoothscroll' not working with wrapped lines and virt text above
Problem: When 'smoothscroll' is enabled, wrapped lines with virtual text above do not scroll smoothly. Solution: Do not count skipped virtual text above multiple times and do not count its width again when skipping to the first displayed character (Yamagi). related: #21336 closes: #21556 Assisted-by: Claude Signed-off-by: Yamagi <yamagi@yamagi.org> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 1258391 commit ec0d714

3 files changed

Lines changed: 62 additions & 1 deletion

File tree

‎src/drawline.c‎

Lines changed: 3 additions & 1 deletion

‎src/testdir/test_textprop.vim‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3631,6 +3631,63 @@ func Test_prop_with_text_above_screenline_motion()
36313631
bwipe!
36323632
endfunc
36333633

3634+
func Test_prop_with_text_above_smoothscroll()
3635+
call NewWindow(6, 40)
3636+
setlocal smoothscroll scrolloff=0
3637+
let rowa = repeat('a', 40)
3638+
let rowb = repeat('b', 40)
3639+
let rowc = repeat('c', 20)
3640+
call setline(1, ['line 1', rowa .. rowb .. rowc]
3641+
\ + map(range(3, 12), '"line " .. v:val'))
3642+
call prop_type_add('test', #{highlight: 'Normal'})
3643+
3644+
let tests = [
3645+
\ ['Example', [
3646+
\ ['line 1', 'Example', rowa, rowb, rowc, 'line 3'],
3647+
\ ['Example', rowa, rowb, rowc, 'line 3', 'line 4'],
3648+
\ ['<<<' .. rowa[3 :], rowb, rowc, 'line 3', 'line 4', 'line 5'],
3649+
\ ['<<<' .. rowb[3 :], rowc, 'line 3', 'line 4', 'line 5', 'line 6'],
3650+
\ ['<<<' .. rowc[3 :], 'line 3', 'line 4', 'line 5', 'line 6',
3651+
\ 'line 7'],
3652+
\ ['line 3', 'line 4', 'line 5', 'line 6', 'line 7', 'line 8'],
3653+
\ ]],
3654+
\ ['Second', [
3655+
\ ['line 1', 'Example', 'Second', rowa, rowb, rowc],
3656+
\ ['Example', 'Second', rowa, rowb, rowc, 'line 3'],
3657+
\ ['<<<ond', rowa, rowb, rowc, 'line 3', 'line 4'],
3658+
\ ['<<<' .. rowa[3 :], rowb, rowc, 'line 3', 'line 4', 'line 5'],
3659+
\ ['<<<' .. rowb[3 :], rowc, 'line 3', 'line 4', 'line 5', 'line 6'],
3660+
\ ['<<<' .. rowc[3 :], 'line 3', 'line 4', 'line 5', 'line 6',
3661+
\ 'line 7'],
3662+
\ ['line 3', 'line 4', 'line 5', 'line 6', 'line 7', 'line 8'],
3663+
\ ]],
3664+
\ ]
3665+
for [vtext, screens] in tests
3666+
call prop_add(2, 0, #{type: 'test', text: vtext, text_align: 'above'})
3667+
normal! gg
3668+
redraw
3669+
call assert_equal(screens[0],
3670+
\ ScreenLines([1, 6], 40)->map('trim(v:val, " ", 2)'))
3671+
for idx in range(1, len(screens) - 1)
3672+
exe "normal! \<C-E>"
3673+
redraw
3674+
call assert_equal(screens[idx],
3675+
\ ScreenLines([1, 6], 40)->map('trim(v:val, " ", 2)'),
3676+
\ vtext .. ': CTRL-E to screen ' .. idx)
3677+
endfor
3678+
for idx in range(len(screens) - 2, 0, -1)
3679+
exe "normal! \<C-Y>"
3680+
redraw
3681+
call assert_equal(screens[idx],
3682+
\ ScreenLines([1, 6], 40)->map('trim(v:val, " ", 2)'),
3683+
\ vtext .. ': CTRL-Y to screen ' .. idx)
3684+
endfor
3685+
endfor
3686+
3687+
call prop_type_delete('test')
3688+
bwipe!
3689+
endfunc
3690+
36343691
func Test_prop_with_text_below_after_match()
36353692
CheckScreendump
36363693
CheckRunVimInTerminal

‎src/version.c‎

Lines changed: 2 additions & 0 deletions

0 commit comments

Comments
 (0)