aboutsummaryrefslogtreecommitdiff
path: root/test/functional/legacy/conceal_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/legacy/conceal_spec.lua')
-rw-r--r--test/functional/legacy/conceal_spec.lua269
1 files changed, 269 insertions, 0 deletions
diff --git a/test/functional/legacy/conceal_spec.lua b/test/functional/legacy/conceal_spec.lua
index 9a23d16c5b..e2cc3b23df 100644
--- a/test/functional/legacy/conceal_spec.lua
+++ b/test/functional/legacy/conceal_spec.lua
@@ -4,6 +4,7 @@ local clear = helpers.clear
local command = helpers.command
local exec = helpers.exec
local feed = helpers.feed
+local api = helpers.api
local expect_pos = function(row, col)
return helpers.eq({ row, col }, helpers.eval('[screenrow(), screencol()]'))
@@ -433,6 +434,68 @@ describe('Conceal', function()
]])
end)
+ -- oldtest: Test_conceal_wrapped_cursorline_wincolor()
+ it('CursorLine highlight on wrapped lines', function()
+ local screen = Screen.new(40, 4)
+ screen:set_default_attr_ids({
+ [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText
+ [1] = { background = Screen.colors.Green }, -- CursorLine (low-priority)
+ [2] = { foreground = Screen.colors.Red }, -- CursorLine (high-priority)
+ })
+ screen:attach()
+ exec([[
+ call setline(1, 'one one one |hidden| one one one one one one one one')
+ syntax match test /|hidden|/ conceal
+ set conceallevel=2 concealcursor=n cursorline
+ normal! g$
+ hi! CursorLine guibg=Green
+ ]])
+ screen:expect([[
+ {1:one one one one one one one on^e }|
+ {1: one one one }|
+ {0:~ }|
+ |
+ ]])
+ command('hi! CursorLine guibg=NONE guifg=Red')
+ screen:expect([[
+ {2:one one one one one one one on^e }|
+ {2: one one one }|
+ {0:~ }|
+ |
+ ]])
+ end)
+
+ -- oldtest: Test_conceal_wrapped_cursorline_wincolor_rightleft()
+ it('CursorLine highlight on wrapped lines with rightleft', function()
+ local screen = Screen.new(40, 4)
+ screen:set_default_attr_ids({
+ [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText
+ [1] = { background = Screen.colors.Green }, -- CursorLine (low-priority)
+ [2] = { foreground = Screen.colors.Red }, -- CursorLine (high-priority)
+ })
+ screen:attach()
+ exec([[
+ call setline(1, 'one one one |hidden| one one one one one one one one')
+ syntax match test /|hidden|/ conceal
+ set conceallevel=2 concealcursor=n cursorline rightleft
+ normal! g$
+ hi! CursorLine guibg=Green
+ ]])
+ screen:expect([[
+ {1: ^eno eno eno eno eno eno eno eno}|
+ {1: eno eno eno }|
+ {0: ~}|
+ |
+ ]])
+ command('hi! CursorLine guibg=NONE guifg=Red')
+ screen:expect([[
+ {2: ^eno eno eno eno eno eno eno eno}|
+ {2: eno eno eno }|
+ {0: ~}|
+ |
+ ]])
+ end)
+
-- oldtest: Test_conceal_resize_term()
it('resize editor', function()
local screen = Screen.new(75, 6)
@@ -570,4 +633,210 @@ describe('Conceal', function()
feed('$')
expect_pos(9, 26)
end)
+
+ local function test_conceal_virtualedit_after_eol(wrap)
+ local screen = Screen.new(60, 3)
+ screen:set_default_attr_ids({
+ [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText
+ })
+ screen:attach()
+ api.nvim_set_option_value('wrap', wrap, {})
+ exec([[
+ call setline(1, 'abcdefgh|hidden|ijklmnpop')
+ syntax match test /|hidden|/ conceal
+ set conceallevel=2 concealcursor=n virtualedit=all
+ normal! $
+ ]])
+ screen:expect([[
+ abcdefghijklmnpo^p |
+ {0:~ }|
+ |
+ ]])
+ feed('l')
+ screen:expect([[
+ abcdefghijklmnpop^ |
+ {0:~ }|
+ |
+ ]])
+ feed('l')
+ screen:expect([[
+ abcdefghijklmnpop ^ |
+ {0:~ }|
+ |
+ ]])
+ feed('l')
+ screen:expect([[
+ abcdefghijklmnpop ^ |
+ {0:~ }|
+ |
+ ]])
+ feed('rr')
+ screen:expect([[
+ abcdefghijklmnpop ^r |
+ {0:~ }|
+ |
+ ]])
+ end
+
+ -- oldtest: Test_conceal_virtualedit_after_eol()
+ describe('cursor drawn at correct column with virtualedit', function()
+ it('with wrapping', function()
+ test_conceal_virtualedit_after_eol(true)
+ end)
+ it('without wrapping', function()
+ test_conceal_virtualedit_after_eol(false)
+ end)
+ end)
+
+ local function test_conceal_virtualedit_after_eol_rightleft(wrap)
+ local screen = Screen.new(60, 3)
+ screen:set_default_attr_ids({
+ [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText
+ })
+ screen:attach()
+ api.nvim_set_option_value('wrap', wrap, {})
+ exec([[
+ call setline(1, 'abcdefgh|hidden|ijklmnpop')
+ syntax match test /|hidden|/ conceal
+ set conceallevel=2 concealcursor=n virtualedit=all rightleft
+ normal! $
+ ]])
+ screen:expect([[
+ ^popnmlkjihgfedcba|
+ {0: ~}|
+ |
+ ]])
+ feed('h')
+ screen:expect([[
+ ^ popnmlkjihgfedcba|
+ {0: ~}|
+ |
+ ]])
+ feed('h')
+ screen:expect([[
+ ^ popnmlkjihgfedcba|
+ {0: ~}|
+ |
+ ]])
+ feed('h')
+ screen:expect([[
+ ^ popnmlkjihgfedcba|
+ {0: ~}|
+ |
+ ]])
+ feed('rr')
+ screen:expect([[
+ ^r popnmlkjihgfedcba|
+ {0: ~}|
+ |
+ ]])
+ end
+
+ -- oldtest: Test_conceal_virtualedit_after_eol_rightleft()
+ describe('cursor drawn correctly with virtualedit and rightleft', function()
+ it('with wrapping', function()
+ test_conceal_virtualedit_after_eol_rightleft(true)
+ end)
+ it('without wrapping', function()
+ test_conceal_virtualedit_after_eol_rightleft(false)
+ end)
+ end)
+
+ local function test_conceal_double_width(wrap)
+ local screen = Screen.new(60, 4)
+ screen:set_default_attr_ids({
+ [0] = { bold = true, foreground = Screen.colors.Blue },
+ [1] = { background = Screen.colors.DarkGrey, foreground = Screen.colors.LightGrey },
+ [2] = { background = Screen.colors.LightRed },
+ })
+ screen:attach()
+ api.nvim_set_option_value('wrap', wrap, {})
+ exec([[
+ call setline(1, ['aaaaa口=口bbbbb口=口ccccc', 'foobar'])
+ syntax match test /口=口/ conceal cchar=β
+ set conceallevel=2 concealcursor=n colorcolumn=30
+ normal! $
+ ]])
+ screen:expect([[
+ aaaaa{1:β}bbbbb{1:β}cccc^c {2: } |
+ foobar {2: } |
+ {0:~ }|
+ |
+ ]])
+ feed('gM')
+ screen:expect([[
+ aaaaa{1:β}bb^bbb{1:β}ccccc {2: } |
+ foobar {2: } |
+ {0:~ }|
+ |
+ ]])
+ command('set conceallevel=3')
+ screen:expect([[
+ aaaaabb^bbbccccc {2: } |
+ foobar {2: } |
+ {0:~ }|
+ |
+ ]])
+ feed('$')
+ screen:expect([[
+ aaaaabbbbbcccc^c {2: } |
+ foobar {2: } |
+ {0:~ }|
+ |
+ ]])
+ end
+
+ -- oldtest: Test_conceal_double_width()
+ describe('cursor drawn correctly when double-width chars are concealed', function()
+ it('with wrapping', function()
+ test_conceal_double_width(true)
+ end)
+ it('without wrapping', function()
+ test_conceal_double_width(false)
+ end)
+ end)
+
+ -- oldtest: Test_conceal_double_width_wrap()
+ it('line wraps correctly when double-width chars are concealed', function()
+ local screen = Screen.new(20, 4)
+ screen:set_default_attr_ids({
+ [0] = { bold = true, foreground = Screen.colors.Blue },
+ [1] = { background = Screen.colors.DarkGrey, foreground = Screen.colors.LightGrey },
+ [2] = { background = Screen.colors.LightRed },
+ })
+ screen:attach()
+ exec([[
+ call setline(1, 'aaaaaaaaaa口=口bbbbbbbbbb口=口cccccccccc')
+ syntax match test /口=口/ conceal cchar=β
+ set conceallevel=2 concealcursor=n
+ normal! $
+ ]])
+ screen:expect([[
+ aaaaaaaaaa{1:β}bbbbb |
+ bbbbb{1:β}ccccccccc^c |
+ {0:~ }|
+ |
+ ]])
+ feed('gM')
+ screen:expect([[
+ aaaaaaaaaa{1:β}bbbbb |
+ ^bbbbb{1:β}cccccccccc |
+ {0:~ }|
+ |
+ ]])
+ command('set conceallevel=3')
+ screen:expect([[
+ aaaaaaaaaabbbbb |
+ ^bbbbbcccccccccc |
+ {0:~ }|
+ |
+ ]])
+ feed('$')
+ screen:expect([[
+ aaaaaaaaaabbbbb |
+ bbbbbccccccccc^c |
+ {0:~ }|
+ |
+ ]])
+ end)
end)