diff options
author | Luuk van Baal <luukvbaal@gmail.com> | 2023-01-12 10:40:53 +0100 |
---|---|---|
committer | Luuk van Baal <luukvbaal@gmail.com> | 2023-01-16 14:03:09 +0100 |
commit | 85111ca0f4916ade5caa4e1ca836d615afdba6f8 (patch) | |
tree | d4f3886f812530e2d8bbb0aeef418ac74eab4b2a /test/functional/ui/statuscolumn_spec.lua | |
parent | ef89f9fd46ab591183b7f59f31f5a2e55f7a526b (diff) | |
download | rneovim-85111ca0f4916ade5caa4e1ca836d615afdba6f8.tar.gz rneovim-85111ca0f4916ade5caa4e1ca836d615afdba6f8.tar.bz2 rneovim-85111ca0f4916ade5caa4e1ca836d615afdba6f8.zip |
fix(column)!: ensure 'statuscolumn' works with virtual and wrapped lines
Problem: The `'statuscolumn'` was not re-evaluated for wrapped lines,
when preceded by virtual/filler lines. There was also no way
to distinguish virtual and wrapped lines in the status column.
Solution: Make sure to rebuild the statuscolumn, and replace variable
`v:wrap` with `v:virtnum`. `v:virtnum` is negative when drawing
virtual lines, zero when drawing the actual buffer line, and
positive when drawing the wrapped part of a buffer line.
Diffstat (limited to 'test/functional/ui/statuscolumn_spec.lua')
-rw-r--r-- | test/functional/ui/statuscolumn_spec.lua | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index a9d796c10b..fd57d5dfba 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -4,6 +4,7 @@ local clear = helpers.clear local command = helpers.command local eq = helpers.eq local eval = helpers.eval +local exec = helpers.exec_lua local meths = helpers.meths local pcall_err = helpers.pcall_err @@ -183,7 +184,7 @@ describe('statuscolumn', function() end) it('works with wrapped lines, signs and folds', function() - command("set stc=%C%s%=%{v:wrap?'':v:lnum}│\\ ") + command("set stc=%C%s%=%{v:virtnum?'':v:lnum}│\\ ") command("call setline(1,repeat([repeat('aaaaa',10)],16))") screen:set_default_attr_ids({ [0] = {bold = true, foreground = Screen.colors.Blue}, @@ -234,7 +235,7 @@ describe('statuscolumn', function() ]]) command('norm zf$') -- Check that alignment works properly with signs after %= - command("set stc=%C%=%{v:wrap?'':v:lnum}│%s\\ ") + command("set stc=%C%=%{v:virtnum?'':v:lnum}│%s\\ ") screen:expect([[ {2: }{1: 4│>>}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: │}{2: }{1: }aaaaaa | @@ -304,7 +305,7 @@ describe('statuscolumn', function() {2: }{1: 2│}{2: }{1: }aaaaaa | | ]]) - command("set stc=%C%=\\ %{v:wrap?'':v:relnum}│%s\\ ") + command([[set stc=%C%=\ %{v:virtnum?'':v:relnum}│%s\ ]]) screen:expect([[ {2: }{1: 4│>>}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: │}{2: }{1: }aaaaaa | @@ -346,6 +347,34 @@ describe('statuscolumn', function() {2: }{1: │}{2: }{1: }aaaaaaaaaaaaaaaaaaaa | | ]]) + -- Status column is re-evaluated for virt_lines, buffer line, and wrapped line + exec([[ + local ns = vim.api.nvim_create_namespace("ns") + vim.api.nvim_buf_set_extmark(0, ns, 4, 0, { + virt_lines = {{{"virt_line", ""}}, {{"virt_line", ""}}} + }) + vim.api.nvim_buf_set_extmark(0, ns, 5, 0, { + virt_lines_above = true, virt_lines = {{{"virt_line above", ""}}, {{"virt_line above", ""}}} + }) + ]]) + command('set foldcolumn=0 signcolumn=no') + command([[set stc=%{v:virtnum<0?'virtual':(!v:virtnum?'buffer':'wrapped')}%=%{'\ '.v:virtnum.'\ '.v:lnum}]]) + screen:expect([[ + {1:buffer 0 4}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {1:wrapped 1 4}aaaaaaaa | + {1:buffer 0 5}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {1:wrapped 1 5}aaaaaaaa | + {1:virtual-4 5}virt_line | + {1:virtual-4 5}virt_line | + {1:virtual-4 5}virt_line above | + {1:virtual-4 5}virt_line above | + {1:buffer 0 6}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {1:wrapped 1 6}aaaaaaaa | + {1:buffer 0 7}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {1:wrapped 1 7}aaaaaaaa | + {4:buffer 0 8}{5:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| + | + ]]) end) it('works with \'statuscolumn\' clicks', function() |