From a1d71ad55e0f7149f284178b2d04ac78263b09ff Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 23 Aug 2023 10:12:00 +0800 Subject: vim-patch:9.0.1783: Display issues with virt text smoothscroll and showbreak Problem: Wrong display with wrapping virtual text or unprintable chars, 'showbreak' and 'smoothscroll'. Solution: Don't skip cells taken by 'showbreak' in screen lines before "w_skipcol". Combined "n_skip" and "skip_cells". closes: vim/vim#12597 https://github.com/vim/vim/commit/b557f4898208105b674df605403cac1b1292707b --- test/old/testdir/test_listlbr.vim | 47 ++++++++++++++++++- test/old/testdir/test_listlbr_utf8.vim | 83 +++++++++++++++++++++++++++++++++- 2 files changed, 126 insertions(+), 4 deletions(-) (limited to 'test/old') diff --git a/test/old/testdir/test_listlbr.vim b/test/old/testdir/test_listlbr.vim index 2e66fd4ccb..9b9bf63864 100644 --- a/test/old/testdir/test_listlbr.vim +++ b/test/old/testdir/test_listlbr.vim @@ -14,7 +14,7 @@ function s:screen_lines(lnum, width) abort endfunction func s:compare_lines(expect, actual) - call assert_equal(join(a:expect, "\n"), join(a:actual, "\n")) + call assert_equal(a:expect, a:actual) endfunc function s:test_windows(...) @@ -330,4 +330,47 @@ func Test_list_with_tab_and_skipping_first_chars() \ ] call s:compare_lines(expect, lines) call s:close_windows() -endfu +endfunc + +func Test_ctrl_char_on_wrap_column() + call s:test_windows("setl nolbr wrap sbr=") + call setline(1, 'aaa' .. repeat("\", 150) .. 'bbb') + call cursor(1,1) + norm! $ + redraw! + let expect=[ +\ '<<<^A^A^A^A^A^A^A^A^', +\ 'A^A^A^A^A^A^A^A^A^A^', +\ 'A^A^A^A^A^A^A^A^A^A^', +\ 'A^A^A^A^A^A^A^A^A^A^', +\ 'A^A^A^A^A^A^A^A^A^A^', +\ 'A^A^A^A^A^A^A^A^A^A^', +\ 'A^A^A^A^A^A^A^A^A^A^', +\ 'A^A^A^A^A^A^A^A^A^A^', +\ 'A^A^A^A^A^A^A^A^A^A^', +\ 'A^Abbb '] + let lines = s:screen_lines([1, 10], winwidth(0)) + call s:compare_lines(expect, lines) + call assert_equal(len(expect), winline()) + call assert_equal(strwidth(trim(expect[-1], ' ', 2)), wincol()) + setl sbr=!! + redraw! + let expect=[ +\ '!!A^A^A^A^A^A^A^A^A^', +\ '!!A^A^A^A^A^A^A^A^A^', +\ '!!A^A^A^A^A^A^A^A^A^', +\ '!!A^A^A^A^A^A^A^A^A^', +\ '!!A^A^A^A^A^A^A^A^A^', +\ '!!A^A^A^A^A^A^A^A^A^', +\ '!!A^A^A^A^A^A^A^A^A^', +\ '!!A^A^A^A^A^A^A^A^A^', +\ '!!A^A^A^A^A^A^A^A^A^', +\ '!!A^A^A^A^A^A^Abbb '] + let lines = s:screen_lines([1, 10], winwidth(0)) + call s:compare_lines(expect, lines) + call assert_equal(len(expect), winline()) + call assert_equal(strwidth(trim(expect[-1], ' ', 2)), wincol()) + call s:close_windows() +endfunc + +" vim: shiftwidth=2 sts=2 expandtab diff --git a/test/old/testdir/test_listlbr_utf8.vim b/test/old/testdir/test_listlbr_utf8.vim index 15b248964f..1bbbd2d2ae 100644 --- a/test/old/testdir/test_listlbr_utf8.vim +++ b/test/old/testdir/test_listlbr_utf8.vim @@ -249,7 +249,6 @@ endfunc func Test_chinese_char_on_wrap_column() call s:test_windows("setl nolbr wrap sbr=") - syntax off call setline(1, [ \ 'aaaaaaaaaaaaaaaaaaa中'. \ 'aaaaaaaaaaaaaaaaa中'. @@ -278,5 +277,85 @@ func Test_chinese_char_on_wrap_column() \ '中hello '] let lines = s:screen_lines([1, 10], winwidth(0)) call s:compare_lines(expect, lines) + call assert_equal(len(expect), winline()) + call assert_equal(strwidth(trim(expect[-1], ' ', 2)), wincol()) call s:close_windows() -endfu +endfunc + +func Test_chinese_char_on_wrap_column_sbr() + call s:test_windows("setl nolbr wrap sbr=!!!") + call setline(1, [ +\ 'aaaaaaaaaaaaaaaaaaa中'. +\ 'aaaaaaaaaaaaaa中'. +\ 'aaaaaaaaaaaaaa中'. +\ 'aaaaaaaaaaaaaa中'. +\ 'aaaaaaaaaaaaaa中'. +\ 'aaaaaaaaaaaaaa中'. +\ 'aaaaaaaaaaaaaa中'. +\ 'aaaaaaaaaaaaaa中'. +\ 'aaaaaaaaaaaaaa中'. +\ 'aaaaaaaaaaaaaa中'. +\ 'hello']) + call cursor(1,1) + norm! $ + redraw! + let expect=[ +\ '!!!中aaaaaaaaaaaaaa>', +\ '!!!中aaaaaaaaaaaaaa>', +\ '!!!中aaaaaaaaaaaaaa>', +\ '!!!中aaaaaaaaaaaaaa>', +\ '!!!中aaaaaaaaaaaaaa>', +\ '!!!中aaaaaaaaaaaaaa>', +\ '!!!中aaaaaaaaaaaaaa>', +\ '!!!中aaaaaaaaaaaaaa>', +\ '!!!中aaaaaaaaaaaaaa>', +\ '!!!中hello '] + let lines = s:screen_lines([1, 10], winwidth(0)) + call s:compare_lines(expect, lines) + call assert_equal(len(expect), winline()) + call assert_equal(strwidth(trim(expect[-1], ' ', 2)), wincol()) + call s:close_windows() +endfunc + +func Test_unprintable_char_on_wrap_column() + call s:test_windows("setl nolbr wrap sbr=") + call setline(1, 'aaa' .. repeat("\uFEFF", 50) .. 'bbb') + call cursor(1,1) + norm! $ + redraw! + let expect=[ +\ '<<<<', +\ 'feff><', +\ 'feff><', +\ 'feff>bbb '] + let lines = s:screen_lines([1, 10], winwidth(0)) + call s:compare_lines(expect, lines) + call assert_equal(len(expect), winline()) + call assert_equal(strwidth(trim(expect[-1], ' ', 2)), wincol()) + setl sbr=!! + redraw! + let expect=[ +\ '!!>bbb '] + let lines = s:screen_lines([1, 10], winwidth(0)) + call s:compare_lines(expect, lines) + call assert_equal(len(expect), winline()) + call assert_equal(strwidth(trim(expect[-1], ' ', 2)), wincol()) + call s:close_windows() +endfunc + +" vim: shiftwidth=2 sts=2 expandtab -- cgit