mirror of
https://github.com/neovim/neovim.git
synced 2025-10-10 03:46:31 +00:00
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.
This commit is contained in:
@@ -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()
|
||||
|
Reference in New Issue
Block a user