aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-08-23 10:12:00 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-08-23 13:17:17 +0800
commita1d71ad55e0f7149f284178b2d04ac78263b09ff (patch)
treeb20f28212e0fd952a046d0e4150c7c26e54336fc /test
parent3e80b39a8ef9d33090800642d25fadbd282af337 (diff)
downloadrneovim-a1d71ad55e0f7149f284178b2d04ac78263b09ff.tar.gz
rneovim-a1d71ad55e0f7149f284178b2d04ac78263b09ff.tar.bz2
rneovim-a1d71ad55e0f7149f284178b2d04ac78263b09ff.zip
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
Diffstat (limited to 'test')
-rw-r--r--test/functional/ui/decorations_spec.lua328
-rw-r--r--test/old/testdir/test_listlbr.vim47
-rw-r--r--test/old/testdir/test_listlbr_utf8.vim83
3 files changed, 451 insertions, 7 deletions
diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua
index ed562555e3..9bbd28c3cb 100644
--- a/test/functional/ui/decorations_spec.lua
+++ b/test/functional/ui/decorations_spec.lua
@@ -2021,7 +2021,7 @@ bbbbbbb]])
]]}
end)
- it('cursor position is correct with virtual text attached to hard tabs', function()
+ it('cursor position is correct with virtual text attached to hard TABs', function()
command('set noexpandtab')
feed('i')
feed('<TAB>')
@@ -2692,7 +2692,7 @@ bbbbbbb]])
]]}
end)
- it('correctly draws when overflowing virtual text is followed by tab with no wrap', function()
+ it('correctly draws when overflowing virtual text is followed by TAB with no wrap', function()
command('set nowrap')
feed('i<TAB>test<ESC>')
meths.buf_set_extmark(
@@ -2984,6 +2984,328 @@ bbbbbbb]])
{8:-- VISUAL BLOCK --} |
]]}
end)
+
+ local function test_virt_inline_showbreak_smoothscroll()
+ screen:try_resize(30, 6)
+ exec([[
+ highlight! link LineNr Normal
+ call setline(1, repeat('a', 28))
+ setlocal number showbreak=+ breakindent breakindentopt=shift:2
+ setlocal scrolloff=0 smoothscroll
+ normal! $
+ ]])
+ meths.buf_set_extmark(0, ns, 0, 27, { virt_text = { { ('123'):rep(23) } }, virt_text_pos = 'inline' })
+ feed(':<CR>') -- Have a screen line that doesn't start with spaces
+ screen:expect{grid=[[
+ 1 aaaaaaaaaaaaaaaaaaaaaaaaaa|
+ {1:+}a1231231231231231231231|
+ {1:+}23123123123123123123123|
+ {1:+}12312312312312312312312|
+ {1:+}3^a |
+ : |
+ ]]}
+ feed('<C-E>')
+ screen:expect{grid=[[
+ {1:+}a1231231231231231231231|
+ {1:+}23123123123123123123123|
+ {1:+}12312312312312312312312|
+ {1:+}3^a |
+ {1:~ }|
+ : |
+ ]]}
+ feed('<C-E>')
+ screen:expect{grid=[[
+ {1:+}23123123123123123123123|
+ {1:+}12312312312312312312312|
+ {1:+}3^a |
+ {1:~ }|
+ {1:~ }|
+ : |
+ ]]}
+ feed('<C-E>')
+ screen:expect{grid=[[
+ {1:+}12312312312312312312312|
+ {1:+}3^a |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ : |
+ ]]}
+ feed('<C-E>')
+ screen:expect{grid=[[
+ {1:+}3^a |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ : |
+ ]]}
+ feed('zbi')
+ screen:expect{grid=[[
+ 1 aaaaaaaaaaaaaaaaaaaaaaaaaa|
+ {1:+}a^1231231231231231231231|
+ {1:+}23123123123123123123123|
+ {1:+}12312312312312312312312|
+ {1:+}3a |
+ {8:-- INSERT --} |
+ ]]}
+ feed('<BS>')
+ screen:expect{grid=[[
+ 1 aaaaaaaaaaaaaaaaaaaaaaaaaa|
+ {1:+}^12312312312312312312312|
+ {1:+}31231231231231231231231|
+ {1:+}23123123123123123123123|
+ {1:+}a |
+ {8:-- INSERT --} |
+ ]]}
+ feed('<Esc>l')
+ feed(':<CR>') -- Have a screen line that doesn't start with spaces
+ screen:expect{grid=[[
+ 1 aaaaaaaaaaaaaaaaaaaaaaaaaa|
+ {1:+}12312312312312312312312|
+ {1:+}31231231231231231231231|
+ {1:+}23123123123123123123123|
+ {1:+}^a |
+ : |
+ ]]}
+ feed('<C-E>')
+ screen:expect{grid=[[
+ {1:+}12312312312312312312312|
+ {1:+}31231231231231231231231|
+ {1:+}23123123123123123123123|
+ {1:+}^a |
+ {1:~ }|
+ : |
+ ]]}
+ feed('<C-E>')
+ screen:expect{grid=[[
+ {1:+}31231231231231231231231|
+ {1:+}23123123123123123123123|
+ {1:+}^a |
+ {1:~ }|
+ {1:~ }|
+ : |
+ ]]}
+ feed('<C-E>')
+ screen:expect{grid=[[
+ {1:+}23123123123123123123123|
+ {1:+}^a |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ : |
+ ]]}
+ feed('<C-E>')
+ screen:expect{grid=[[
+ {1:+}^a |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ : |
+ ]]}
+ feed('023x$')
+ screen:expect{grid=[[
+ 1 aaa12312312312312312312312|
+ {1:+}31231231231231231231231|
+ {1:+}23123123123123123123123|
+ {1:+}^a |
+ {1:~ }|
+ : |
+ ]]}
+ feed('<C-E>')
+ screen:expect{grid=[[
+ {1:+}31231231231231231231231|
+ {1:+}23123123123123123123123|
+ {1:+}^a |
+ {1:~ }|
+ {1:~ }|
+ : |
+ ]]}
+ feed('<C-E>')
+ screen:expect{grid=[[
+ {1:+}23123123123123123123123|
+ {1:+}^a |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ : |
+ ]]}
+ feed('<C-E>')
+ screen:expect{grid=[[
+ {1:+}^a |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ : |
+ ]]}
+ feed('zbi')
+ screen:expect{grid=[[
+ 1 aaa^12312312312312312312312|
+ {1:+}31231231231231231231231|
+ {1:+}23123123123123123123123|
+ {1:+}a |
+ {1:~ }|
+ {8:-- INSERT --} |
+ ]]}
+ feed('<C-U>')
+ screen:expect{grid=[[
+ 1 ^12312312312312312312312312|
+ {1:+}31231231231231231231231|
+ {1:+}23123123123123123123a |
+ {1:~ }|
+ {1:~ }|
+ {8:-- INSERT --} |
+ ]]}
+ feed('<Esc>')
+ screen:expect{grid=[[
+ 1 12312312312312312312312312|
+ {1:+}31231231231231231231231|
+ {1:+}23123123123123123123^a |
+ {1:~ }|
+ {1:~ }|
+ |
+ ]]}
+ feed('<C-E>')
+ screen:expect{grid=[[
+ {1:+}31231231231231231231231|
+ {1:+}23123123123123123123^a |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ |
+ ]]}
+ feed('<C-E>')
+ screen:expect{grid=[[
+ {1:+}23123123123123123123^a |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ |
+ ]]}
+ end
+
+ describe('with showbreak, smoothscroll', function()
+ it('and cpoptions-=n', function()
+ test_virt_inline_showbreak_smoothscroll()
+ end)
+
+ it('and cpoptions+=n', function()
+ command('set cpoptions+=n')
+ -- because of 'breakindent' the screen states are the same
+ test_virt_inline_showbreak_smoothscroll()
+ end)
+ end)
+
+ it('before TABs with smoothscroll', function()
+ screen:try_resize(30, 6)
+ exec([[
+ call setline(1, repeat("\t", 4) .. 'a')
+ setlocal list listchars=tab:<-> scrolloff=0 smoothscroll
+ normal! $
+ ]])
+ meths.buf_set_extmark(0, ns, 0, 3, { virt_text = { { ('12'):rep(32) } }, virt_text_pos = 'inline' })
+ screen:expect{grid=[[
+ {1:<------><------><------>}121212|
+ 121212121212121212121212121212|
+ 1212121212121212121212121212{1:<-}|
+ {1:----->}^a |
+ {1:~ }|
+ |
+ ]]}
+ feed('<C-E>')
+ screen:expect{grid=[[
+ {1:<<<}212121212121212121212121212|
+ 1212121212121212121212121212{1:<-}|
+ {1:----->}^a |
+ {1:~ }|
+ {1:~ }|
+ |
+ ]]}
+ feed('<C-E>')
+ screen:expect{grid=[[
+ {1:<<<}2121212121212121212121212{1:<-}|
+ {1:----->}^a |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ |
+ ]]}
+ feed('<C-E>')
+ screen:expect{grid=[[
+ {1:<<<-->}^a |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ |
+ ]]}
+ feed('zbh')
+ screen:expect{grid=[[
+ {1:<------><------><------>}121212|
+ 121212121212121212121212121212|
+ 1212121212121212121212121212{1:^<-}|
+ {1:----->}a |
+ {1:~ }|
+ |
+ ]]}
+ feed('i')
+ screen:expect{grid=[[
+ {1:<------><------><------>}^121212|
+ 121212121212121212121212121212|
+ 1212121212121212121212121212{1:<-}|
+ {1:----->}a |
+ {1:~ }|
+ {8:-- INSERT --} |
+ ]]}
+ feed('<C-O>:setlocal nolist<CR>')
+ screen:expect{grid=[[
+ ^121212|
+ 121212121212121212121212121212|
+ 1212121212121212121212121212 |
+ a |
+ {1:~ }|
+ {8:-- INSERT --} |
+ ]]}
+ feed('<Esc>l')
+ screen:expect{grid=[[
+ 121212|
+ 121212121212121212121212121212|
+ 1212121212121212121212121212 |
+ ^ a |
+ {1:~ }|
+ |
+ ]]}
+ feed('<C-E>')
+ screen:expect{grid=[[
+ {1:<<<}212121212121212121212121212|
+ 1212121212121212121212121212 |
+ ^ a |
+ {1:~ }|
+ {1:~ }|
+ |
+ ]]}
+ feed('<C-E>')
+ screen:expect{grid=[[
+ {1:<<<}2121212121212121212121212 |
+ ^ a |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ |
+ ]]}
+ feed('<C-E>')
+ screen:expect{grid=[[
+ {1:<<<} ^ a |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ |
+ ]]}
+ end)
end)
describe('decorations: virtual lines', function()
@@ -3643,7 +3965,7 @@ if (h->n_buckets < new_n_buckets) { // expand
end)
- it('works with hard tabs', function()
+ it('works with hard TABs', function()
insert(example_text2)
feed 'gg'
meths.buf_set_extmark(0, ns, 1, 0, {
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("\<C-A>", 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',
+\ '><feff><feff><feff><',
+\ 'feff><feff><feff><fe',
+\ 'ff><feff><feff><feff',
+\ '><feff><feff><feff><',
+\ 'feff><feff><feff><fe',
+\ 'ff><feff><feff><feff',
+\ '><feff><feff><feff><',
+\ 'feff><feff><feff><fe',
+\ 'ff>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=[
+\ '!!><feff><feff><feff',
+\ '!!><feff><feff><feff',
+\ '!!><feff><feff><feff',
+\ '!!><feff><feff><feff',
+\ '!!><feff><feff><feff',
+\ '!!><feff><feff><feff',
+\ '!!><feff><feff><feff',
+\ '!!><feff><feff><feff',
+\ '!!><feff><feff><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())
+ call s:close_windows()
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab