aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui
diff options
context:
space:
mode:
authorLuuk van Baal <luukvbaal@gmail.com>2024-11-23 23:03:46 +0100
committerluukvbaal <luukvbaal@gmail.com>2025-02-25 13:09:01 +0100
commitf58e7d5fac1c4f63f0ba3e59134591239182910e (patch)
tree1b180a27cb3c4f4f521188b8e6416d3adfc79206 /test/functional/ui
parenta31ccc3b1f65fd86780c03fec9c6e1bf56e30e35 (diff)
downloadrneovim-f58e7d5fac1c4f63f0ba3e59134591239182910e.tar.gz
rneovim-f58e7d5fac1c4f63f0ba3e59134591239182910e.tar.bz2
rneovim-f58e7d5fac1c4f63f0ba3e59134591239182910e.zip
feat(marks): add conceal_lines to nvim_buf_set_extmark()
Implement an extmark property that conceals lines vertically.
Diffstat (limited to 'test/functional/ui')
-rw-r--r--test/functional/ui/decorations_spec.lua221
1 files changed, 221 insertions, 0 deletions
diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua
index 99e6b5f78f..1d0021363b 100644
--- a/test/functional/ui/decorations_spec.lua
+++ b/test/functional/ui/decorations_spec.lua
@@ -2625,6 +2625,227 @@ describe('extmark decorations', function()
|
]])
end)
+
+ it ('conceal_lines', function()
+ insert(example_text)
+ exec('set number conceallevel=3')
+ feed('ggj')
+ local not_concealed = {
+ grid = [[
+ {2: 1 }for _,item in ipairs(items) do |
+ {2: 2 }^ local text, hl_id_cell, count = unpack(ite|
+ {2: }m) |
+ {2: 3 } if hl_id_cell ~= nil then |
+ {2: 4 } hl_id = hl_id_cell |
+ {2: 5 } end |
+ {2: 6 } for _ = 1, (count or 1) do |
+ {2: 7 } local cell = line[colpos] |
+ {2: 8 } cell.text = text |
+ {2: 9 } cell.hl_id = hl_id |
+ {2: 10 } colpos = colpos+1 |
+ {2: 11 } end |
+ {2: 12 }end |
+ {1:~ }|
+ |
+ ]]
+ }
+ screen:expect(not_concealed)
+ api.nvim_buf_set_extmark(0, ns, 1, 0, { conceal_lines = "" })
+ screen:expect_unchanged()
+ feed('j')
+ local concealed = {
+ grid = [[
+ {2: 1 }for _,item in ipairs(items) do |
+ {2: 3 }^ if hl_id_cell ~= nil then |
+ {2: 4 } hl_id = hl_id_cell |
+ {2: 5 } end |
+ {2: 6 } for _ = 1, (count or 1) do |
+ {2: 7 } local cell = line[colpos] |
+ {2: 8 } cell.text = text |
+ {2: 9 } cell.hl_id = hl_id |
+ {2: 10 } colpos = colpos+1 |
+ {2: 11 } end |
+ {2: 12 }end |
+ {1:~ }|*3
+ |
+ ]]
+ }
+ screen:expect(concealed)
+ feed('k')
+ screen:expect(not_concealed)
+ exec('set concealcursor=n')
+ screen:expect(concealed)
+ api.nvim_buf_set_extmark(0, ns, 3, 0, { conceal_lines = "" })
+ screen:expect({
+ grid = [[
+ {2: 1 }for _,item in ipairs(items) do |
+ {2: 3 }^ if hl_id_cell ~= nil then |
+ {2: 5 } end |
+ {2: 6 } for _ = 1, (count or 1) do |
+ {2: 7 } local cell = line[colpos] |
+ {2: 8 } cell.text = text |
+ {2: 9 } cell.hl_id = hl_id |
+ {2: 10 } colpos = colpos+1 |
+ {2: 11 } end |
+ {2: 12 }end |
+ {1:~ }|*4
+ |
+ ]]
+ })
+ feed('kjj')
+ screen:expect_unchanged()
+ api.nvim_buf_set_extmark(0, ns, 4, 0, { conceal_lines = "" })
+ feed('kjjjC')
+ screen:expect({
+ grid = [[
+ {2: 1 }for _,item in ipairs(items) do |
+ {2: 3 } if hl_id_cell ~= nil then |
+ {2: 5 }^ |
+ {2: 6 } for _ = 1, (count or 1) do |
+ {2: 7 } local cell = line[colpos] |
+ {2: 8 } cell.text = text |
+ {2: 9 } cell.hl_id = hl_id |
+ {2: 10 } colpos = colpos+1 |
+ {2: 11 } end |
+ {2: 12 }end |
+ {1:~ }|*4
+ {24:-- INSERT --} |
+ ]]
+ })
+ feed('<esc>')
+ screen:expect({
+ grid = [[
+ {2: 1 }for _,item in ipairs(items) do |
+ {2: 3 } if hl_id_cell ~= nil then |
+ {2: 6 }^ for _ = 1, (count or 1) do |
+ {2: 7 } local cell = line[colpos] |
+ {2: 8 } cell.text = text |
+ {2: 9 } cell.hl_id = hl_id |
+ {2: 10 } colpos = colpos+1 |
+ {2: 11 } end |
+ {2: 12 }end |
+ {1:~ }|*5
+ |
+ ]]
+ })
+ feed('kji')
+ screen:expect({
+ grid = [[
+ {2: 1 }for _,item in ipairs(items) do |
+ {2: 3 } if hl_id_cell ~= nil then |
+ {2: 5 }^ |
+ {2: 6 } for _ = 1, (count or 1) do |
+ {2: 7 } local cell = line[colpos] |
+ {2: 8 } cell.text = text |
+ {2: 9 } cell.hl_id = hl_id |
+ {2: 10 } colpos = colpos+1 |
+ {2: 11 } end |
+ {2: 12 }end |
+ {1:~ }|*4
+ {24:-- INSERT --} |
+ ]]
+ })
+ feed('conceal text')
+ screen:expect({
+ grid = [[
+ {2: 1 }for _,item in ipairs(items) do |
+ {2: 3 } if hl_id_cell ~= nil then |
+ {2: 5 }conceal text^ |
+ {2: 6 } for _ = 1, (count or 1) do |
+ {2: 7 } local cell = line[colpos] |
+ {2: 8 } cell.text = text |
+ {2: 9 } cell.hl_id = hl_id |
+ {2: 10 } colpos = colpos+1 |
+ {2: 11 } end |
+ {2: 12 }end |
+ {1:~ }|*4
+ {24:-- INSERT --} |
+ ]]
+ })
+ feed('<esc>')
+ screen:expect({
+ grid = [[
+ {2: 1 }for _,item in ipairs(items) do |
+ {2: 3 } if hl_id_cell ~= nil then |
+ {2: 6 } for _ =^ 1, (count or 1) do |
+ {2: 7 } local cell = line[colpos] |
+ {2: 8 } cell.text = text |
+ {2: 9 } cell.hl_id = hl_id |
+ {2: 10 } colpos = colpos+1 |
+ {2: 11 } end |
+ {2: 12 }end |
+ {1:~ }|*5
+ |
+ ]]
+ })
+ feed('ggzfj')
+ screen:expect({
+ grid = [[
+ {2: 1 }{33:^+-- 2 lines: for _,item in ipairs(items) do··}|
+ {2: 3 } if hl_id_cell ~= nil then |
+ {2: 6 } for _ = 1, (count or 1) do |
+ {2: 7 } local cell = line[colpos] |
+ {2: 8 } cell.text = text |
+ {2: 9 } cell.hl_id = hl_id |
+ {2: 10 } colpos = colpos+1 |
+ {2: 11 } end |
+ {2: 12 }end |
+ {1:~ }|*5
+ |
+ ]]
+ })
+ feed('j')
+ screen:expect({
+ grid = [[
+ {2: 1 }{33:+-- 2 lines: for _,item in ipairs(items) do··}|
+ {2: 3 }^ if hl_id_cell ~= nil then |
+ {2: 6 } for _ = 1, (count or 1) do |
+ {2: 7 } local cell = line[colpos] |
+ {2: 8 } cell.text = text |
+ {2: 9 } cell.hl_id = hl_id |
+ {2: 10 } colpos = colpos+1 |
+ {2: 11 } end |
+ {2: 12 }end |
+ {1:~ }|*5
+ |
+ ]]
+ })
+ feed('ggzdjzfj')
+ screen:expect({
+ grid = [[
+ {2: 1 }for _,item in ipairs(items) do |
+ {2: 6 }^ for _ = 1, (count or 1) do |
+ {2: 7 } local cell = line[colpos] |
+ {2: 8 } cell.text = text |
+ {2: 9 } cell.hl_id = hl_id |
+ {2: 10 } colpos = colpos+1 |
+ {2: 11 } end |
+ {2: 12 }end |
+ {1:~ }|*6
+ |
+ ]]
+ })
+ feed('jj')
+ screen:expect_unchanged()
+ -- Below virtual line belonging to line above concealed line is drawn.
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_lines = { { { 'line 1 below' } } } })
+ -- Above virtual line belonging to concealed line isn't.
+ api.nvim_buf_set_extmark(0, ns, 1, 0, {
+ virt_lines = { { { 'line 2 above' } } },
+ virt_lines_above = true
+ })
+ screen:expect([[
+ {2: 1 }for _,item in ipairs(items) do |
+ {2: }line 1 below |
+ {2: 6 }^ for _ = 1, (count or 1) do |
+ {2: 9 } cell.hl_id = hl_id |
+ {2: 10 } colpos = colpos+1 |
+ {2: 11 } end |
+ {2: 12 }end |
+ {1:~ }|*7
+ |
+ ]])
+ end)
end)
describe('decorations: inline virtual text', function()