diff options
author | luukvbaal <31730729+luukvbaal@users.noreply.github.com> | 2023-01-23 00:43:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-23 07:43:04 +0800 |
commit | 323ea17a19911f88c15b36e2251657edfa09b30b (patch) | |
tree | c5887c40d2eeef2d9bcdc874df227546d862bef3 /test/functional/ui/fold_spec.lua | |
parent | 0f633ff494b5b39b5ca410e75ea3357c79657bcd (diff) | |
download | rneovim-323ea17a19911f88c15b36e2251657edfa09b30b.tar.gz rneovim-323ea17a19911f88c15b36e2251657edfa09b30b.tar.bz2 rneovim-323ea17a19911f88c15b36e2251657edfa09b30b.zip |
fix(extmarks): problems with folded virtual lines (#21930)
Problem: When a folded line has virtual lines attached, the following
problems occur:
- The virtual lines are drawn empty.
- The 'foldtext' line is drawn empty.
- The cursor is drawn incorrectly.
Solution: Check whether virtual lines belong to a folded line.
Fix #17027
Fix #19557
Fix #21837
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Diffstat (limited to 'test/functional/ui/fold_spec.lua')
-rw-r--r-- | test/functional/ui/fold_spec.lua | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index bfa7167100..46a478c1ea 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -8,6 +8,7 @@ local expect = helpers.expect local funcs = helpers.funcs local meths = helpers.meths local exec = helpers.exec +local exec_lua = helpers.exec_lua local assert_alive = helpers.assert_alive @@ -1852,6 +1853,128 @@ describe("folded lines", function() ]]) end end) + + it('fold attached virtual lines are drawn 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", ""}}} }) + ]]) + if multigrid then + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + {5:^+-- 2 lines: line 1·························}| + virt_line above line 3 | + line 3 | + line 4 | + virt_line below line 4 | + {1:~ }| + {1:~ }| + ## grid 3 + | + ]]) + else + screen:expect([[ + {5:^+-- 2 lines: line 1·························}| + virt_line above line 3 | + line 3 | + line 4 | + virt_line below line 4 | + {1:~ }| + {1:~ }| + | + ]]) + end + + feed('jzfj') + if multigrid then + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + {5:+-- 2 lines: line 1·························}| + {5:^+-- 2 lines: line 3·························}| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + | + ]]) + else + screen:expect([[ + {5:+-- 2 lines: line 1·························}| + {5:^+-- 2 lines: line 3·························}| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]) + end + + feed('kzo<C-Y>') + funcs.setline(5, 'line 5') + if multigrid then + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + virt_line above line 1 | + ^line 1 | + line 2 | + virt_line below line 2 | + {5:+-- 2 lines: line 3·························}| + line 5 | + {1:~ }| + ## grid 3 + | + ]]) + else + screen:expect([[ + virt_line above line 1 | + ^line 1 | + line 2 | + virt_line below line 2 | + {5:+-- 2 lines: line 3·························}| + line 5 | + {1:~ }| + | + ]]) + end + end) end describe("with ext_multigrid", function() |