aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-06-05 06:58:44 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-06-05 08:45:32 +0800
commit7955c90621bb679f9c16b6788fbcb6145739886f (patch)
treebabfc7fab6873ff516a0c3fe1dbc4708a20f883f /test
parent57fef392d265e2ef40c8c514749d658cb4d8d22a (diff)
downloadrneovim-7955c90621bb679f9c16b6788fbcb6145739886f.tar.gz
rneovim-7955c90621bb679f9c16b6788fbcb6145739886f.tar.bz2
rneovim-7955c90621bb679f9c16b6788fbcb6145739886f.zip
fix(plines): folded lines with virt_lines attached to line above
Diffstat (limited to 'test')
-rw-r--r--test/functional/ui/fold_spec.lua232
-rw-r--r--test/functional/vimscript/screenpos_spec.lua50
2 files changed, 259 insertions, 23 deletions
diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua
index 520979a2c2..06668c0ba3 100644
--- a/test/functional/ui/fold_spec.lua
+++ b/test/functional/ui/fold_spec.lua
@@ -7,7 +7,6 @@ local insert = helpers.insert
local funcs = helpers.funcs
local meths = helpers.meths
local exec = helpers.exec
-local exec_lua = helpers.exec_lua
local assert_alive = helpers.assert_alive
@@ -1911,19 +1910,17 @@ describe("folded lines", function()
end
end)
- it('fold attached virtual lines are drawn correctly #21837', function()
+ it('fold attached virtual lines are drawn and scrolled correctly #21837', function()
funcs.setline(1, 'line 1')
funcs.setline(2, 'line 2')
funcs.setline(3, 'line 3')
funcs.setline(4, 'line 4')
feed("zfj")
- exec_lua([[
- local ns = vim.api.nvim_create_namespace("ns")
- vim.api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_lines_above = true, virt_lines = {{{"virt_line above line 1", ""}}} })
- vim.api.nvim_buf_set_extmark(0, ns, 1, 0, { virt_lines = {{{"virt_line below line 2", ""}}} })
- vim.api.nvim_buf_set_extmark(0, ns, 2, 0, { virt_lines_above = true, virt_lines = {{{"virt_line above line 3", ""}}} })
- vim.api.nvim_buf_set_extmark(0, ns, 3, 0, { virt_lines = {{{"virt_line below line 4", ""}}} })
- ]])
+ local ns = meths.create_namespace('ns')
+ meths.buf_set_extmark(0, ns, 0, 0, { virt_lines_above = true, virt_lines = {{{"virt_line above line 1", ""}}} })
+ meths.buf_set_extmark(0, ns, 1, 0, { virt_lines = {{{"virt_line below line 2", ""}}} })
+ meths.buf_set_extmark(0, ns, 2, 0, { virt_lines_above = true, virt_lines = {{{"virt_line above line 3", ""}}} })
+ meths.buf_set_extmark(0, ns, 3, 0, { virt_lines = {{{"virt_line below line 4", ""}}} })
if multigrid then
screen:expect([[
## grid 1
@@ -2031,6 +2028,223 @@ describe("folded lines", function()
|
]])
end
+
+ meths.buf_set_extmark(0, ns, 1, 0, { virt_lines = {{{"more virt_line below line 2", ""}}} })
+ feed('G<C-E>')
+ if multigrid then
+ screen:expect([[
+ ## grid 1
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [3:---------------------------------------------]|
+ ## grid 2
+ line 1 |
+ line 2 |
+ virt_line below line 2 |
+ more virt_line below line 2 |
+ {5:+-- 2 lines: line 3·························}|
+ ^line 5 |
+ {1:~ }|
+ ## grid 3
+ |
+ ]])
+ else
+ screen:expect([[
+ line 1 |
+ line 2 |
+ virt_line below line 2 |
+ more virt_line below line 2 |
+ {5:+-- 2 lines: line 3·························}|
+ ^line 5 |
+ {1:~ }|
+ |
+ ]])
+ end
+
+ feed('<C-E>')
+ if multigrid then
+ screen:expect([[
+ ## grid 1
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [3:---------------------------------------------]|
+ ## grid 2
+ line 2 |
+ virt_line below line 2 |
+ more virt_line below line 2 |
+ {5:+-- 2 lines: line 3·························}|
+ ^line 5 |
+ {1:~ }|
+ {1:~ }|
+ ## grid 3
+ |
+ ]])
+ else
+ screen:expect([[
+ line 2 |
+ virt_line below line 2 |
+ more virt_line below line 2 |
+ {5:+-- 2 lines: line 3·························}|
+ ^line 5 |
+ {1:~ }|
+ {1:~ }|
+ |
+ ]])
+ end
+
+ feed('<C-E>')
+ if multigrid then
+ screen:expect([[
+ ## grid 1
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [3:---------------------------------------------]|
+ ## grid 2
+ virt_line below line 2 |
+ more virt_line below line 2 |
+ {5:+-- 2 lines: line 3·························}|
+ ^line 5 |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ ## grid 3
+ |
+ ]])
+ else
+ screen:expect([[
+ virt_line below line 2 |
+ more virt_line below line 2 |
+ {5:+-- 2 lines: line 3·························}|
+ ^line 5 |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ |
+ ]])
+ end
+
+ feed('<C-E>')
+ if multigrid then
+ screen:expect([[
+ ## grid 1
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [3:---------------------------------------------]|
+ ## grid 2
+ more virt_line below line 2 |
+ {5:+-- 2 lines: line 3·························}|
+ ^line 5 |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ ## grid 3
+ |
+ ]])
+ else
+ screen:expect([[
+ more virt_line below line 2 |
+ {5:+-- 2 lines: line 3·························}|
+ ^line 5 |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ |
+ ]])
+ end
+
+ feed('<C-E>')
+ if multigrid then
+ screen:expect([[
+ ## grid 1
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [3:---------------------------------------------]|
+ ## grid 2
+ {5:+-- 2 lines: line 3·························}|
+ ^line 5 |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ ## grid 3
+ |
+ ]])
+ else
+ screen:expect([[
+ {5:+-- 2 lines: line 3·························}|
+ ^line 5 |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ |
+ ]])
+ end
+
+ feed('<C-E>')
+ if multigrid then
+ screen:expect([[
+ ## grid 1
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [3:---------------------------------------------]|
+ ## grid 2
+ ^line 5 |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ ## grid 3
+ |
+ ]])
+ else
+ screen:expect([[
+ ^line 5 |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ |
+ ]])
+ end
end)
it('Folded and Visual highlights are combined #19691', function()
diff --git a/test/functional/vimscript/screenpos_spec.lua b/test/functional/vimscript/screenpos_spec.lua
index 75e5c02298..8b8276457d 100644
--- a/test/functional/vimscript/screenpos_spec.lua
+++ b/test/functional/vimscript/screenpos_spec.lua
@@ -1,12 +1,12 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, eq, meths = helpers.clear, helpers.eq, helpers.meths
local command, funcs = helpers.command, helpers.funcs
+local feed = helpers.feed
before_each(clear)
describe('screenpos() function', function()
it('works in floating window with border', function()
- local bufnr = meths.create_buf(false, true)
local opts = {
relative='editor',
height=8,
@@ -18,34 +18,56 @@ describe('screenpos() function', function()
border='none',
focusable=1
}
- local float = meths.open_win(bufnr, false, opts)
+ local float = meths.open_win(meths.create_buf(false, true), false, opts)
command('redraw')
- local pos = funcs.screenpos(bufnr, 1, 1)
- eq(7, pos.row)
- eq(9, pos.col)
+ eq({row = 7, col = 9, endcol = 9, curscol = 9}, funcs.screenpos(float, 1, 1))
-- only left border
opts.border = {'', '', '', '', '', '', '', '|'}
meths.win_set_config(float, opts)
command('redraw')
- pos = funcs.screenpos(bufnr, 1, 1)
- eq(7, pos.row)
- eq(10, pos.col)
+ eq({row = 7, col = 10, endcol = 10, curscol = 10}, funcs.screenpos(float, 1, 1))
-- only top border
opts.border = {'', '_', '', '', '', '', '', ''}
meths.win_set_config(float, opts)
command('redraw')
- pos = funcs.screenpos(bufnr, 1, 1)
- eq(8, pos.row)
- eq(9, pos.col)
+ eq({row = 8, col = 9, endcol = 9, curscol = 9}, funcs.screenpos(float, 1, 1))
-- both left and top border
opts.border = 'single'
meths.win_set_config(float, opts)
command('redraw')
- pos = funcs.screenpos(bufnr, 1, 1)
- eq(8, pos.row)
- eq(10, pos.col)
+ eq({row = 8, col = 10, endcol = 10, curscol = 10}, funcs.screenpos(float, 1, 1))
+ end)
+
+ it('works for folded line with virt_lines attached to line above', function()
+ meths.buf_set_lines(0, 0, -1, true, {'aaa', 'bbb', 'ccc', 'ddd'})
+ local ns = meths.create_namespace('')
+ meths.buf_set_extmark(0, ns, 0, 0, { virt_lines = {{{'abb'}}, {{'acc'}}, {{'add'}}} })
+ command('2,3fold')
+ eq({row = 5, col = 1, endcol = 1, curscol = 1}, funcs.screenpos(0, 2, 1))
+ eq({row = 5, col = 1, endcol = 1, curscol = 1}, funcs.screenpos(0, 3, 1))
+ eq({row = 6, col = 1, endcol = 1, curscol = 1}, funcs.screenpos(0, 4, 1))
+
+ feed('<C-E>')
+ eq({row = 4, col = 1, endcol = 1, curscol = 1}, funcs.screenpos(0, 2, 1))
+ eq({row = 4, col = 1, endcol = 1, curscol = 1}, funcs.screenpos(0, 3, 1))
+ eq({row = 5, col = 1, endcol = 1, curscol = 1}, funcs.screenpos(0, 4, 1))
+
+ feed('<C-E>')
+ eq({row = 3, col = 1, endcol = 1, curscol = 1}, funcs.screenpos(0, 2, 1))
+ eq({row = 3, col = 1, endcol = 1, curscol = 1}, funcs.screenpos(0, 3, 1))
+ eq({row = 4, col = 1, endcol = 1, curscol = 1}, funcs.screenpos(0, 4, 1))
+
+ feed('<C-E>')
+ eq({row = 2, col = 1, endcol = 1, curscol = 1}, funcs.screenpos(0, 2, 1))
+ eq({row = 2, col = 1, endcol = 1, curscol = 1}, funcs.screenpos(0, 3, 1))
+ eq({row = 3, col = 1, endcol = 1, curscol = 1}, funcs.screenpos(0, 4, 1))
+
+ feed('<C-E>')
+ eq({row = 1, col = 1, endcol = 1, curscol = 1}, funcs.screenpos(0, 2, 1))
+ eq({row = 1, col = 1, endcol = 1, curscol = 1}, funcs.screenpos(0, 3, 1))
+ eq({row = 2, col = 1, endcol = 1, curscol = 1}, funcs.screenpos(0, 4, 1))
end)
end)