aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2025-02-05 23:09:29 +0000
committerJosh Rahm <joshuarahm@gmail.com>2025-02-05 23:09:29 +0000
commitd5f194ce780c95821a855aca3c19426576d28ae0 (patch)
treed45f461b19f9118ad2bb1f440a7a08973ad18832 /test/functional/ui
parentc5d770d311841ea5230426cc4c868e8db27300a8 (diff)
parent44740e561fc93afe3ebecfd3618bda2d2abeafb0 (diff)
downloadrneovim-rahm.tar.gz
rneovim-rahm.tar.bz2
rneovim-rahm.zip
Merge remote-tracking branch 'upstream/master' into mix_20240309HEADrahm
Diffstat (limited to 'test/functional/ui')
-rw-r--r--test/functional/ui/cmdline_spec.lua122
-rw-r--r--test/functional/ui/cursor_spec.lua56
-rw-r--r--test/functional/ui/decorations_spec.lua401
-rw-r--r--test/functional/ui/diff_spec.lua20
-rw-r--r--test/functional/ui/float_spec.lua384
-rw-r--r--test/functional/ui/hlstate_spec.lua10
-rw-r--r--test/functional/ui/inccommand_user_spec.lua44
-rw-r--r--test/functional/ui/input_spec.lua4
-rw-r--r--test/functional/ui/linematch_spec.lua28
-rw-r--r--test/functional/ui/messages_spec.lua798
-rw-r--r--test/functional/ui/mode_spec.lua40
-rw-r--r--test/functional/ui/multigrid_spec.lua2
-rw-r--r--test/functional/ui/output_spec.lua4
-rw-r--r--test/functional/ui/popupmenu_spec.lua604
-rw-r--r--test/functional/ui/screen.lua58
-rw-r--r--test/functional/ui/screen_basic_spec.lua59
-rw-r--r--test/functional/ui/sign_spec.lua202
-rw-r--r--test/functional/ui/statuscolumn_spec.lua177
-rw-r--r--test/functional/ui/statusline_spec.lua505
-rw-r--r--test/functional/ui/syntax_conceal_spec.lua33
-rw-r--r--test/functional/ui/title_spec.lua57
21 files changed, 2752 insertions, 856 deletions
diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua
index 0221c1e0b0..ce7c9596bb 100644
--- a/test/functional/ui/cmdline_spec.lua
+++ b/test/functional/ui/cmdline_spec.lua
@@ -91,25 +91,27 @@ local function test_cmdline(linegrid)
{1:~ }|*3
|
]],
+ cmdline = { { abort = true } },
}
end)
it('works with input()', function()
feed(':call input("input", "default")<cr>')
- screen:expect {
+ screen:expect({
grid = [[
- ^ |
- {1:~ }|*3
- |
- ]],
+ ^ |
+ {1:~ }|*3
+ |
+ ]],
cmdline = {
{
- prompt = 'input',
content = { { 'default' } },
+ hl_id = 0,
pos = 7,
+ prompt = 'input',
},
},
- }
+ })
feed('<cr>')
screen:expect {
@@ -118,6 +120,7 @@ local function test_cmdline(linegrid)
{1:~ }|*3
|
]],
+ cmdline = { { abort = false } },
}
end)
@@ -210,6 +213,7 @@ local function test_cmdline(linegrid)
content = { { 'xx3' } },
pos = 3,
},
+ { abort = false },
},
}
@@ -220,6 +224,7 @@ local function test_cmdline(linegrid)
{1:~ }|*3
|
]],
+ cmdline = { { abort = true } },
}
end)
@@ -294,6 +299,7 @@ local function test_cmdline(linegrid)
{1:~ }|*3
|
]],
+ cmdline = { { abort = false } },
}
-- Try once more, to check buffer is reinitialized. #8007
@@ -324,6 +330,7 @@ local function test_cmdline(linegrid)
{1:~ }|*3
|
]],
+ cmdline = { { abort = false } },
}
end)
@@ -353,6 +360,7 @@ local function test_cmdline(linegrid)
{3:[Command Line] }|
|
]],
+ cmdline = { { abort = false } },
}
-- nested cmdline
@@ -404,6 +412,7 @@ local function test_cmdline(linegrid)
{3:[Command Line] }|
|
]],
+ cmdline = { [2] = { abort = true } },
}
feed('<c-c>')
@@ -452,6 +461,7 @@ local function test_cmdline(linegrid)
cmdline = {
{
prompt = 'secret:',
+ hl_id = 0,
content = { { '******' } },
pos = 6,
},
@@ -495,6 +505,7 @@ local function test_cmdline(linegrid)
cmdline = {
{
prompt = '>',
+ hl_id = 0,
content = {
{ '(', 30 },
{ 'a' },
@@ -797,11 +808,14 @@ local function test_cmdline(linegrid)
-- This used to send an invalid event where pos where larger than the total
-- length of content. Checked in _handle_cmdline_show.
feed('<esc>')
- screen:expect([[
- ^ |
- {1:~ }|*3
- |
- ]])
+ screen:expect({
+ grid = [[
+ ^ |
+ {1:~ }|*3
+ |
+ ]],
+ cmdline = { { abort = true } },
+ })
end)
it('does not move cursor to curwin #20309', function()
@@ -827,6 +841,30 @@ local function test_cmdline(linegrid)
} },
}
end)
+
+ it('show prompt hl_id', function()
+ screen:expect([[
+ ^ |
+ {1:~ }|*3
+ |
+ ]])
+ feed(':echohl Error | call input("Prompt:")<CR>')
+ screen:expect({
+ grid = [[
+ ^ |
+ {1:~ }|*3
+ |
+ ]],
+ cmdline = {
+ {
+ content = { { '' } },
+ hl_id = 242,
+ pos = 0,
+ prompt = 'Prompt:',
+ },
+ },
+ })
+ end)
end
-- the representation of cmdline and cmdline_block contents changed with ext_linegrid
@@ -1000,6 +1038,36 @@ describe('cmdline redraw', function()
]],
}
end)
+
+ it('silent prompt', function()
+ command([[nmap <silent> T :call confirm("Save changes?", "&Yes\n&No\n&Cancel")<CR>]])
+ feed('T')
+ screen:expect([[
+ |
+ {3: }|
+ |
+ {6:Save changes?} |
+ {6:[Y]es, (N)o, (C)ancel: }^ |
+ ]])
+ end)
+
+ it('substitute confirm prompt does not scroll', function()
+ screen:try_resize(75, screen._height)
+ command('call setline(1, "foo")')
+ command('set report=0')
+ feed(':%s/foo/bar/c<CR>')
+ screen:expect([[
+ {2:foo} |
+ {1:~ }|*3
+ {6:replace with bar? (y)es/(n)o/(a)ll/(q)uit/(l)ast/scroll up(^E)/down(^Y)}^ |
+ ]])
+ feed('y')
+ screen:expect([[
+ ^bar |
+ {1:~ }|*3
+ 1 substitution on 1 line |
+ ]])
+ end)
end)
describe('statusline is redrawn on entering cmdline', function()
@@ -1447,31 +1515,29 @@ describe('cmdheight=0', function()
it('when substitute text', function()
command('set cmdheight=0 noruler laststatus=3')
feed('ifoo<ESC>')
- screen:expect {
- grid = [[
+ screen:try_resize(screen._width, 7)
+ screen:expect([[
fo^o |
- {1:~ }|*3
+ {1:~ }|*5
{3:[No Name] [+] }|
- ]],
- }
+ ]])
feed(':%s/foo/bar/gc<CR>')
- screen:expect {
- grid = [[
+ screen:expect([[
{2:foo} |
- {1:~ }|*3
- {6:replace wi...q/l/^E/^Y)?}^ |
- ]],
- }
+ {3: }|
+ |*2
+ {6:replace with bar? (y)es/(}|
+ {6:n)o/(a)ll/(q)uit/(l)ast/s}|
+ {6:croll up(^E)/down(^Y)}^ |
+ ]])
feed('y')
- screen:expect {
- grid = [[
+ screen:expect([[
^bar |
- {1:~ }|*3
+ {1:~ }|*5
{3:[No Name] [+] }|
- ]],
- }
+ ]])
assert_alive()
end)
diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua
index d7c0657820..825a90fbc8 100644
--- a/test/functional/ui/cursor_spec.lua
+++ b/test/functional/ui/cursor_spec.lua
@@ -190,6 +190,19 @@ describe('ui/cursor', function()
attr_lm = {},
short_name = 'sm',
},
+ [18] = {
+ blinkoff = 500,
+ blinkon = 500,
+ blinkwait = 0,
+ cell_percentage = 0,
+ cursor_shape = 'block',
+ name = 'terminal',
+ hl_id = 3,
+ id_lm = 3,
+ attr = { reverse = true },
+ attr_lm = { reverse = true },
+ short_name = 't',
+ },
}
screen:expect(function()
@@ -245,17 +258,20 @@ describe('ui/cursor', function()
end
end
if m.hl_id then
- m.hl_id = 66
+ m.hl_id = 65
m.attr = { background = Screen.colors.DarkGray }
end
if m.id_lm then
- m.id_lm = 73
+ m.id_lm = 72
+ m.attr_lm = {}
end
end
-- Assert the new expectation.
screen:expect(function()
- eq(expected_mode_info, screen._mode_info)
+ for i, v in ipairs(expected_mode_info) do
+ eq(v, screen._mode_info[i])
+ end
eq(true, screen._cursor_style_enabled)
eq('normal', screen.mode)
end)
@@ -361,4 +377,38 @@ describe('ui/cursor', function()
end
end)
end)
+
+ it(':sleep does not hide cursor when sleeping', function()
+ n.feed(':sleep 100m | echo 42\n')
+ screen:expect({
+ grid = [[
+ ^ |
+ {1:~ }|*3
+ :sleep 100m | echo 42 |
+ ]],
+ timeout = 100,
+ })
+ screen:expect([[
+ ^ |
+ {1:~ }|*3
+ 42 |
+ ]])
+ end)
+
+ it(':sleep! hides cursor when sleeping', function()
+ n.feed(':sleep! 100m | echo 42\n')
+ screen:expect({
+ grid = [[
+ |
+ {1:~ }|*3
+ :sleep! 100m | echo 42 |
+ ]],
+ timeout = 100,
+ })
+ screen:expect([[
+ ^ |
+ {1:~ }|*3
+ 42 |
+ ]])
+ end)
end)
diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua
index fbf16f3afe..7969dd5d3b 100644
--- a/test/functional/ui/decorations_spec.lua
+++ b/test/functional/ui/decorations_spec.lua
@@ -509,6 +509,69 @@ describe('decorations providers', function()
]]}
end)
+ it('can have virtual text of the style: eol_right_align', function()
+ insert(mulholland)
+ setup_provider [[
+ local hl = api.nvim_get_hl_id_by_name "ErrorMsg"
+ local test_ns = api.nvim_create_namespace "mulholland"
+ function on_do(event, ...)
+ if event == "line" then
+ local win, buf, line = ...
+ api.nvim_buf_set_extmark(buf, test_ns, line, 0, {
+ virt_text = {{'+'}, {'1234567890', 'ErrorMsg'}};
+ virt_text_pos='eol_right_align';
+ ephemeral = true;
+ })
+ end
+ end
+ ]]
+
+ screen:expect{grid=[[
+ // just to see if there was an accident |
+ // on Mulholland Drive +{2:1234567890}|
+ try_start(); +{2:1234567890}|
+ bufref_T save_buf; +{2:1234567890}|
+ switch_buffer(&save_buf, buf); +{2:12345678}|
+ posp = getmark(mark, false); +{2:1234567890}|
+ restore_buffer(&save_buf);^ +{2:1234567890}|
+ |
+ ]]}
+ end)
+
+ it('multiple eol_right_align', function()
+ insert(mulholland)
+ setup_provider [[
+ local hl = api.nvim_get_hl_id_by_name "ErrorMsg"
+ local test_ns = api.nvim_create_namespace "mulholland"
+ function on_do(event, ...)
+ if event == "line" then
+ local win, buf, line = ...
+ api.nvim_buf_set_extmark(buf, test_ns, line, 0, {
+ virt_text = {{'11111'}};
+ virt_text_pos='eol_right_align';
+ ephemeral = true;
+ })
+ api.nvim_buf_set_extmark(0, test_ns, line, 0, {
+ virt_text = {{'22222'}};
+ virt_text_pos='eol_right_align';
+ ephemeral = true;
+ })
+ end
+ end
+ ]]
+
+ screen:expect{grid=[[
+ // just to see if there was an accident |
+ // on Mulholland Drive 11111 22222|
+ try_start(); 11111 22222|
+ bufref_T save_buf; 11111 22222|
+ switch_buffer(&save_buf, buf); 11111 222|
+ posp = getmark(mark, false); 11111 22222|
+ restore_buffer(&save_buf);^ 11111 22222|
+ |
+ ]]}
+ end)
+
it('virtual text works with wrapped lines', function()
insert(mulholland)
feed('ggJj3JjJ')
@@ -631,7 +694,7 @@ describe('decorations providers', function()
{14: }hello97 |
{14: }hello98 |
{14: }hello99 |
- X ^hello100 |
+ {14:X }^hello100 |
{14: }hello101 |
{14: }hello102 |
{14: }hello103 |
@@ -744,6 +807,30 @@ describe('decorations providers', function()
]])
eq(2, exec_lua([[return _G.cnt]]))
end)
+
+ it('can do large changes to the marktree', function()
+ insert("line1 with a lot of text\nline2 with a lot of text")
+ setup_provider([[
+ function on_do(event, _, _, row)
+ if event == 'win' or (event == 'line' and row == 1) then
+ vim.api.nvim_buf_clear_namespace(0, ns1, 0, -1)
+ for i = 0,1 do
+ for j = 0,23 do
+ vim.api.nvim_buf_set_extmark(0, ns1, i, j, {hl_group='ErrorMsg', end_col = j+1})
+ end
+ end
+ end
+ end
+ ]])
+
+ -- Doesn't crash when modifying the marktree between line1 and line2
+ screen:expect([[
+ {2:line1 with a lot of text} |
+ {2:line2 with a lot of tex^t} |
+ {1:~ }|*5
+ |
+ ]])
+ end)
end)
local example_text = [[
@@ -810,6 +897,9 @@ describe('extmark decorations', function()
[42] = {undercurl = true, special = Screen.colors.Red};
[43] = {background = Screen.colors.Yellow, undercurl = true, special = Screen.colors.Red};
[44] = {background = Screen.colors.LightMagenta};
+ [45] = { background = Screen.colors.Red, special = Screen.colors.Red, foreground = Screen.colors.Red };
+ [46] = { background = Screen.colors.Blue, foreground = Screen.colors.Blue, special = Screen.colors.Red };
+ [47] = { background = Screen.colors.Green, foreground = Screen.colors.Blue, special = Screen.colors.Red };
}
ns = api.nvim_create_namespace 'test'
@@ -1900,6 +1990,46 @@ describe('extmark decorations', function()
]]}
end)
+ it('highlight can combine multiple groups', function()
+ screen:try_resize(50, 3)
+ command('hi Group1 guibg=Red guifg=Red guisp=Red')
+ command('hi Group2 guibg=Blue guifg=Blue')
+ command('hi Group3 guibg=Green')
+ insert([[example text]])
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { end_row=1, hl_group = {} })
+ screen:expect([[
+ example tex^t |
+ {1:~ }|
+ |
+ ]])
+
+ api.nvim_buf_clear_namespace(0, ns, 0, -1)
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { end_row=1, hl_group = {'Group1'} })
+ screen:expect([[
+ {45:example tex^t} |
+ {1:~ }|
+ |
+ ]])
+ api.nvim_buf_clear_namespace(0, ns, 0, -1)
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { end_row = 1, hl_group = {'Group1', 'Group2'} })
+ screen:expect([[
+ {46:example tex^t} |
+ {1:~ }|
+ |
+ ]])
+ api.nvim_buf_clear_namespace(0, ns, 0, -1)
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { end_row = 1, hl_group = {'Group1', 'Group2', 'Group3'}, hl_eol=true })
+ screen:expect([[
+ {47:example tex^t }|
+ {1:~ }|
+ |
+ ]])
+
+ eq('Invalid hl_group: hl_group item',
+ pcall_err(api.nvim_buf_set_extmark, 0, ns, 0, 0, { end_row = 1, hl_group = {'Group1', 'Group2', {'fail'}}, hl_eol=true }))
+ end)
+
+
it('highlight works after TAB with sidescroll #14201', function()
screen:try_resize(50, 3)
command('set nowrap')
@@ -2301,13 +2431,16 @@ describe('extmark decorations', function()
it('works with both hl_group and sign_hl_group', function()
screen:try_resize(50, 3)
+ screen:add_extra_attr_ids({
+ [100] = { background = Screen.colors.WebGray, foreground = Screen.colors.Blue, bold = true },
+ })
insert('abcdefghijklmn')
api.nvim_buf_set_extmark(0, ns, 0, 0, {sign_text='S', sign_hl_group='NonText', hl_group='Error', end_col=14})
- screen:expect{grid=[[
- {1:S }{4:abcdefghijklm^n} |
+ screen:expect([[
+ {100:S }{9:abcdefghijklm^n} |
{1:~ }|
|
- ]]}
+ ]])
end)
it('virt_text_repeat_linebreak repeats virtual text on wrapped lines', function()
@@ -5064,16 +5197,16 @@ l5
api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S'})
- screen:expect{grid=[[
+ screen:expect([[
{7: }^l1 |
- S l2 |
+ {7:S }l2 |
{7: }l3 |
{7: }l4 |
{7: }l5 |
{7: } |
{1:~ }|*3
|
- ]]}
+ ]])
end)
it('can add a single sign (with end row)', function()
@@ -5082,16 +5215,16 @@ l5
api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S', end_row=1})
- screen:expect{grid=[[
+ screen:expect([[
{7: }^l1 |
- S l2 |
+ {7:S }l2 |
{7: }l3 |
{7: }l4 |
{7: }l5 |
{7: } |
{1:~ }|*3
|
- ]]}
+ ]])
end)
it('can add a single sign and text highlight', function()
@@ -5099,16 +5232,16 @@ l5
feed 'gg'
api.nvim_buf_set_extmark(0, ns, 1, 0, {sign_text='S', hl_group='Todo', end_col=1})
- screen:expect{grid=[[
+ screen:expect([[
{7: }^l1 |
- S {100:l}2 |
+ {7:S }{100:l}2 |
{7: }l3 |
{7: }l4 |
{7: }l5 |
{7: } |
{1:~ }|*3
|
- ]]}
+ ]])
api.nvim_buf_clear_namespace(0, ns, 0, -1)
end)
@@ -5119,16 +5252,16 @@ l5
api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S', end_row = 2})
- screen:expect{grid=[[
+ screen:expect([[
{7: }^l1 |
- S l2 |
- S l3 |
+ {7:S }l2 |
+ {7:S }l3 |
{7: }l4 |
{7: }l5 |
{7: } |
{1:~ }|*3
|
- ]]}
+ ]])
end)
it('can add multiple signs (multiple extmarks)', function()
@@ -5138,16 +5271,16 @@ l5
api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S1'})
api.nvim_buf_set_extmark(0, ns, 3, -1, {sign_text='S2', end_row = 4})
- screen:expect{grid=[[
+ screen:expect([[
{7: }^l1 |
- S1l2 |
+ {7:S1}l2 |
{7: }l3 |
- S2l4 |
- S2l5 |
+ {7:S2}l4 |
+ {7:S2}l5 |
{7: } |
{1:~ }|*3
|
- ]]}
+ ]])
end)
it('can add multiple signs (multiple extmarks) 2', function()
@@ -5156,16 +5289,16 @@ l5
api.nvim_buf_set_extmark(0, ns, 3, -1, {sign_text='S1'})
api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S2', end_row = 3})
- screen:expect{grid=[[
+ screen:expect([[
{7: }^l1 |
- S2{7: }l2 |
- S2{7: }l3 |
- S2S1l4 |
+ {7:S2 }l2 |
+ {7:S2 }l3 |
+ {7:S2S1}l4 |
{7: }l5 |
{7: } |
{1:~ }|*3
|
- ]]}
+ ]])
end)
it('can add multiple signs (multiple extmarks) 3', function()
@@ -5176,16 +5309,16 @@ l5
api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S1', end_row=2})
api.nvim_buf_set_extmark(0, ns, 2, -1, {sign_text='S2', end_row=3})
- screen:expect{grid=[[
+ screen:expect([[
{7: }^l1 |
- S1{7: }l2 |
- S2S1l3 |
- S2{7: }l4 |
+ {7:S1 }l2 |
+ {7:S2S1}l3 |
+ {7:S2 }l4 |
{7: }l5 |
{7: } |
{1:~ }|*3
|
- ]]}
+ ]])
end)
it('can add multiple signs (multiple extmarks) 4', function()
@@ -5195,16 +5328,16 @@ l5
api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S1', end_row=0})
api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S2', end_row=1})
- screen:expect{grid=[[
- S1^l1 |
- S2l2 |
+ screen:expect([[
+ {7:S1}^l1 |
+ {7:S2}l2 |
{7: }l3 |
{7: }l4 |
{7: }l5 |
{7: } |
{1:~ }|*3
|
- ]]}
+ ]])
end)
it('works with old signs', function()
@@ -5219,16 +5352,16 @@ l5
api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S4'})
api.nvim_buf_set_extmark(0, ns, 2, -1, {sign_text='S5'})
- screen:expect{grid=[[
- S4S1^l1 |
- S2x l2 |
- S5{7: }l3 |
+ screen:expect([[
+ {7:S4S1}^l1 |
+ {7:S2x }l2 |
+ {7:S5 }l3 |
{7: }l4 |
{7: }l5 |
{7: } |
{1:~ }|*3
|
- ]]}
+ ]])
end)
it('works with old signs (with range)', function()
@@ -5244,16 +5377,16 @@ l5
api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S4'})
api.nvim_buf_set_extmark(0, ns, 2, -1, {sign_text='S5'})
- screen:expect{grid=[[
- S4S3S1^l1 |
- S3S2x l2 |
- S5S3{7: }l3 |
- S3{7: }l4 |
- S3{7: }l5 |
+ screen:expect([[
+ {7:S4S3S1}^l1 |
+ {7:S3S2x }l2 |
+ {7:S5S3 }l3 |
+ {7:S3 }l4 |
+ {7:S3 }l5 |
{7: } |
{1:~ }|*3
|
- ]]}
+ ]])
end)
it('can add a ranged sign (with start out of view)', function()
@@ -5264,14 +5397,14 @@ l5
api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='X', end_row=3})
- screen:expect{grid=[[
- X {7: }^l3 |
- X {7: }l4 |
+ screen:expect([[
+ {7:X }^l3 |
+ {7:X }l4 |
{7: }l5 |
{7: } |
{1:~ }|*5
|
- ]]}
+ ]])
end)
it('can add lots of signs', function()
@@ -5293,11 +5426,11 @@ l5
api.nvim_buf_set_extmark(0, ns, i, -1, { sign_text='Z' })
end
- screen:expect{grid=[[
- Z Y X W {100:a} {100:b} {100:c} {100:d} {100:e} {100:f} {100:g} {100:h} |*8
- Z Y X W {100:a} {100:b} {100:c} {100:d} {100:e} {100:f} {100:g} {100:^h} |
+ screen:expect([[
+ {7:Z Y X W }{100:a} {100:b} {100:c} {100:d} {100:e} {100:f} {100:g} {100:h} |*8
+ {7:Z Y X W }{100:a} {100:b} {100:c} {100:d} {100:e} {100:f} {100:g} {100:^h} |
|
- ]]}
+ ]])
end)
it('works with priority #19716', function()
@@ -5313,20 +5446,20 @@ l5
api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S5', priority=200})
api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S1', priority=1})
- screen:expect{grid=[[
- S5S4O3S2S1^l1 |
+ screen:expect([[
+ {7:S5S4O3S2S1}^l1 |
{7: }l2 |
|
- ]]}
+ ]])
-- Check truncation works too
api.nvim_set_option_value('signcolumn', 'auto', {})
- screen:expect{grid=[[
- S5^l1 |
+ screen:expect([[
+ {7:S5}^l1 |
{7: }l2 |
|
- ]]}
+ ]])
end)
it('does not overflow with many old signs #23852', function()
@@ -5343,21 +5476,21 @@ l5
command([[exe 'sign place 07 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]])
command([[exe 'sign place 08 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]])
command([[exe 'sign place 09 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]])
- screen:expect{grid=[[
- O3O3O3O3O3O3O3O3O3^ |
+ screen:expect([[
+ {7:O3O3O3O3O3O3O3O3O3}^ |
{1:~ }|
|
- ]]}
+ ]])
api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S1', priority=1})
screen:expect_unchanged()
api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S5', priority=200})
- screen:expect{grid=[[
- S5O3O3O3O3O3O3O3O3^ |
+ screen:expect([[
+ {7:S5O3O3O3O3O3O3O3O3}^ |
{1:~ }|
|
- ]]}
+ ]])
assert_alive()
end)
@@ -5383,12 +5516,12 @@ l5
api.nvim_buf_set_extmark(0, ns, 1, -1, {invalidate = true, sign_text='S3'})
feed('2Gdd')
- screen:expect{grid=[[
- S1l1 |
- S1^l3 |
- S1l4 |
+ screen:expect([[
+ {7:S1}l1 |
+ {7:S1}^l3 |
+ {7:S1}l4 |
|
- ]]}
+ ]])
end)
it('correct width with multiple overlapping signs', function()
@@ -5400,36 +5533,36 @@ l5
feed('gg')
local s1 = [[
- S2S1^l1 |
- S3S2l2 |
- S3S2l3 |
+ {7:S2S1}^l1 |
+ {7:S3S2}l2 |
+ {7:S3S2}l3 |
|
]]
- screen:expect{grid=s1}
+ screen:expect(s1)
-- Correct width when :move'ing a line with signs
command('move2')
- screen:expect{grid=[[
- S3{7: }l2 |
- S3S2S1^l1 |
+ screen:expect([[
+ {7:S3 }l2 |
+ {7:S3S2S1}^l1 |
{7: }l3 |
|
- ]]}
+ ]])
command('silent undo')
screen:expect{grid=s1}
command('d')
- screen:expect{grid=[[
- S3S2S1^l2 |
- S3S2{7: }l3 |
+ screen:expect([[
+ {7:S3S2S1}^l2 |
+ {7:S3S2 }l3 |
{7: }l4 |
|
- ]]}
+ ]])
command('d')
- screen:expect{grid=[[
- S3S2S1^l3 |
+ screen:expect([[
+ {7:S3S2S1}^l3 |
{7: }l4 |
{7: }l5 |
|
- ]]}
+ ]])
end)
it('correct width when adding and removing multiple signs', function()
@@ -5452,12 +5585,12 @@ l5
redraw!
call nvim_buf_del_extmark(0, ns, s1)
]])
- screen:expect{grid=[[
- S1^l1 |
- S1l2 |
- S1l3 |
+ screen:expect([[
+ {7:S1}^l1 |
+ {7:S1}l2 |
+ {7:S1}l3 |
|
- ]]}
+ ]])
end)
it('correct width when deleting lines', function()
@@ -5472,12 +5605,12 @@ l5
call nvim_buf_del_extmark(0, ns, s3)
norm 4Gdd
]])
- screen:expect{grid=[[
+ screen:expect([[
{7: }l3 |
- S2S1l5 |
+ {7:S2S1}l5 |
{7: }^ |
|
- ]]}
+ ]])
end)
it('correct width when splitting lines with signs on different columns', function()
@@ -5487,12 +5620,12 @@ l5
api.nvim_buf_set_extmark(0, ns, 0, 0, {sign_text='S1'})
api.nvim_buf_set_extmark(0, ns, 0, 1, {sign_text='S2'})
feed('a<cr><esc>')
- screen:expect{grid=[[
- S1l |
- S2^1 |
+ screen:expect([[
+ {7:S1}l |
+ {7:S2}^1 |
{7: }l2 |
|
- ]]}
+ ]])
end)
it('correct width after wiping a buffer', function()
@@ -5501,12 +5634,12 @@ l5
feed('gg')
local buf = api.nvim_get_current_buf()
api.nvim_buf_set_extmark(buf, ns, 0, 0, { sign_text = 'h' })
- screen:expect{grid=[[
- h ^l1 |
+ screen:expect([[
+ {7:h }^l1 |
{7: }l2 |
{7: }l3 |
|
- ]]}
+ ]])
api.nvim_win_set_buf(0, api.nvim_create_buf(false, true))
api.nvim_buf_delete(buf, {unload=true, force=true})
api.nvim_buf_set_lines(buf, 0, -1, false, {''})
@@ -5537,12 +5670,12 @@ l5
end)
]])
- screen:expect{grid=[[
- S1^l1 |
- S2l2 |
- S4l3 |
+ screen:expect([[
+ {7:S1}^l1 |
+ {7:S2}l2 |
+ {7:S4}l3 |
|
- ]]}
+ ]])
end)
it('no crash with sign after many marks #27137', function()
@@ -5553,11 +5686,11 @@ l5
end
api.nvim_buf_set_extmark(0, ns, 0, 0, {sign_text = 'S1'})
- screen:expect{grid=[[
- S1{9:^a} |
+ screen:expect([[
+ {7:S1}{9:^a} |
{1:~ }|*2
|
- ]]}
+ ]])
end)
it('correct sort order with multiple namespaces and same id', function()
@@ -5565,11 +5698,11 @@ l5
api.nvim_buf_set_extmark(0, ns, 0, 0, {sign_text = 'S1', id = 1})
api.nvim_buf_set_extmark(0, ns2, 0, 0, {sign_text = 'S2', id = 1})
- screen:expect{grid=[[
- S2S1^ |
+ screen:expect([[
+ {7:S2S1}^ |
{1:~ }|*8
|
- ]]}
+ ]])
end)
it('correct number of signs after deleting text (#27046)', function()
@@ -5586,12 +5719,12 @@ l5
api.nvim_buf_set_extmark(0, ns, 30, 0, {end_row = 30, end_col = 3, hl_group = 'Error'})
command('0d29')
- screen:expect{grid=[[
- S4S3S2S1{9:^foo} |
- S5{7: }{9:foo} |
+ screen:expect([[
+ {7:S4S3S2S1}{9:^foo} |
+ {7:S5 }{9:foo} |
{1:~ }|*7
29 fewer lines |
- ]]}
+ ]])
api.nvim_buf_clear_namespace(0, ns, 0, -1)
end)
@@ -5599,21 +5732,17 @@ l5
it([[correct numberwidth with 'signcolumn' set to "number" #28984]], function()
command('set number numberwidth=1 signcolumn=number')
api.nvim_buf_set_extmark(0, ns, 0, 0, { sign_text = 'S1' })
- screen:expect({
- grid = [[
- S1 ^ |
- {1:~ }|*8
- |
- ]]
- })
+ screen:expect([[
+ {7:S1 }^ |
+ {1:~ }|*8
+ |
+ ]])
api.nvim_buf_del_extmark(0, ns, 1)
- screen:expect({
- grid = [[
- {8:1 }^ |
- {1:~ }|*8
- |
- ]]
- })
+ screen:expect([[
+ {8:1 }^ |
+ {1:~ }|*8
+ |
+ ]])
end)
it('supports emoji as signs', function()
@@ -5626,10 +5755,10 @@ l5
api.nvim_buf_set_extmark(0, ns, 4, 0, {sign_text='❤x'})
screen:expect([[
{7: }^l1 |
- 🧑‍🌾l2 |
- ❤️l3 |
- ❤ l4 |
- ❤xl5 |
+ {7:🧑‍🌾}l2 |
+ {7:❤️}l3 |
+ {7:❤ }l4 |
+ {7:❤x}l5 |
{7: } |
{1:~ }|*3
|
diff --git a/test/functional/ui/diff_spec.lua b/test/functional/ui/diff_spec.lua
index 95159011f1..dae373297a 100644
--- a/test/functional/ui/diff_spec.lua
+++ b/test/functional/ui/diff_spec.lua
@@ -2044,6 +2044,26 @@ it('diff mode overlapped diff blocks will be merged', function()
{2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
|
]])
+
+ WriteDiffFiles3('a\nb\nc', 'd\ne', 'b\nf')
+ screen:expect([[
+ {7: }{27:a}{4: }│{7: }{27:d}{4: }│{7: }{27:^b}{4: }|
+ {7: }{27:b}{4: }│{7: }{27:e}{4: }│{7: }{27:f}{4: }|
+ {7: }{22:c }│{7: }{23:---------}│{7: }{23:---------}|
+ {1:~ }│{1:~ }│{1:~ }|*15
+ {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
+ |
+ ]])
+
+ WriteDiffFiles3('a\nb\nc', 'd\ne', 'b')
+ screen:expect([[
+ {7: }{27:a}{4: }│{7: }{27:d}{4: }│{7: }{27:^b}{4: }|
+ {7: }{27:b}{4: }│{7: }{27:e}{4: }│{7: }{23:---------}|
+ {7: }{22:c }│{7: }{23:---------}│{7: }{23:---------}|
+ {1:~ }│{1:~ }│{1:~ }|*15
+ {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
+ |
+ ]])
end)
-- oldtest: Test_diff_topline_noscroll()
diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua
index 57ef9bcff6..15231e0f8c 100644
--- a/test/functional/ui/float_spec.lua
+++ b/test/functional/ui/float_spec.lua
@@ -1012,6 +1012,97 @@ describe('float window', function()
end)
end)
+ it('placed relative to tabline and laststatus', function()
+ local screen = Screen.new(20, 10)
+ screen:add_extra_attr_ids({ [100] = { bold = true, foreground = Screen.colors.Magenta } })
+ command('set showtabline=1 laststatus=1')
+ api.nvim_open_win(0, false, {
+ relative = 'laststatus',
+ border = 'single',
+ anchor = 'SE',
+ width = 5,
+ height = 1,
+ row = 0,
+ col = 1000,
+ })
+ local tabwin = api.nvim_open_win(0, false, {
+ relative = 'tabline',
+ border = 'single',
+ width = 5,
+ height = 1,
+ row = 0,
+ col = 1000,
+ })
+ screen:expect([[
+ ^ {2:┌─────┐}|
+ {1:~ }{2:│}{4: }{2:│}|
+ {1:~ }{2:└─────┘}|
+ {1:~ }|*3
+ {1:~ }{2:┌─────┐}|
+ {1:~ }{2:│}{4: }{2:│}|
+ {1:~ }{2:└─────┘}|
+ |
+ ]])
+ command('tabnew | tabnext')
+ screen:expect([[
+ {5: }{100:3}{5: Name] }{24: No Name]X}|
+ ^ {2:┌─────┐}|
+ {1:~ }{2:│}{4: }{2:│}|
+ {1:~ }{2:└─────┘}|
+ {1:~ }|*2
+ {1:~ }{2:┌─────┐}|
+ {1:~ }{2:│}{4: }{2:│}|
+ {1:~ }{2:└─────┘}|
+ |
+ ]])
+ command('vsplit')
+ screen:expect([[
+ {5: }{100:4}{5: Name] }{24: No Name]X}|
+ ^ {2:┌─────┐}|
+ {1:~ }{2:│}{4: }{2:│}|
+ {1:~ }{2:└─────┘}|
+ {1:~ }{2:│}{1:~}|
+ {1:~ }{2:┌─────┐}|
+ {1:~ }{2:│}{4: }{2:│}|
+ {1:~ }{2:└─────┘}|
+ {3:[No Name] }{2:<}|
+ |
+ ]])
+ command('quit')
+ api.nvim_win_set_config(tabwin, {
+ relative = 'tabline',
+ border = 'single',
+ width = 5,
+ height = 1,
+ row = 1,
+ col = 0,
+ })
+ screen:expect([[
+ {5: }{100:3}{5: Name] }{24: No Name]X}|
+ ^ |
+ {2:┌─────┐}{1: }|
+ {2:│}{4: }{2:│}{1: }|
+ {2:└─────┘}{1: }|
+ {1:~ }|
+ {1:~ }{2:┌─────┐}|
+ {1:~ }{2:│}{4: }{2:│}|
+ {1:~ }{2:└─────┘}|
+ |
+ ]])
+ command('tabonly')
+ screen:expect([[
+ ^ |
+ {2:┌─────┐}{1: }|
+ {2:│}{4: }{2:│}{1: }|
+ {2:└─────┘}{1: }|
+ {1:~ }|*2
+ {1:~ }{2:┌─────┐}|
+ {1:~ }{2:│}{4: }{2:│}|
+ {1:~ }{2:└─────┘}|
+ |
+ ]])
+ end)
+
local function with_ext_multigrid(multigrid)
local screen, attrs
before_each(function()
@@ -1046,6 +1137,8 @@ describe('float window', function()
[26] = {blend = 80, background = Screen.colors.Gray0};
[27] = {foreground = Screen.colors.Black, background = Screen.colors.LightGrey};
[28] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey};
+ [29] = {background = Screen.colors.Yellow1, foreground = Screen.colors.Blue4};
+ [30] = {background = Screen.colors.Grey, foreground = Screen.colors.Blue4, bold = true};
}
screen:set_default_attr_ids(attrs)
end)
@@ -1451,14 +1544,14 @@ describe('float window', function()
[2:----------------------------------------]|*6
[3:----------------------------------------]|
## grid 2
- {19: }{17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }|
+ {19: }{29:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }|
{19: }{14: 2 }{22:y} |
{19: }{14: 3 }{22: } |
{0:~ }|*3
## grid 3
|
## grid 4
- {17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x }|
+ {29:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x }|
{19: }{15:y }|
{19: }{15: }|
{15: }|
@@ -1466,9 +1559,9 @@ describe('float window', function()
else
screen:expect([[
- {19: }{17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }|
+ {19: }{29:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }|
{19: }{14: 2 }{22:y} |
- {19: }{14: 3 }{22: } {17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x } |
+ {19: }{14: 3 }{22: } {29:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x } |
{0:~ }{19: }{15:y }{0: }|
{0:~ }{19: }{15: }{0: }|
{0:~ }{15: }{0: }|
@@ -1551,14 +1644,14 @@ describe('float window', function()
[2:----------------------------------------]|*6
[3:----------------------------------------]|
## grid 2
- {19: }{17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }|
+ {19: }{29:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }|
{19: }{14: 2 }{22:y} |
{19: }{14: 3 }{22: } |
{0:~ }|*3
## grid 3
|
## grid 4
- {17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x }|
+ {29:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x }|
{19: }{15:y }|
{19: }{15: }|
{15: }|
@@ -1566,9 +1659,9 @@ describe('float window', function()
else
screen:expect([[
- {19: }{17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }|
+ {19: }{29:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }|
{19: }{14: 2 }{22:y} |
- {19: }{14: 3 }{22: } {17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x } |
+ {19: }{14: 3 }{22: } {29:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x } |
{0:~ }{19: }{15:y }{0: }|
{0:~ }{19: }{15: }{0: }|
{0:~ }{15: }{0: }|
@@ -1616,31 +1709,34 @@ describe('float window', function()
feed('ix<cr>y<cr><esc>gg')
api.nvim_open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10, style='minimal'})
if multigrid then
- screen:expect{grid=[[
- ## grid 1
- [2:----------------------------------------]|*6
- [3:----------------------------------------]|
- ## grid 2
- {20: 1}{19: }{22:^x}{21: }|
- {14: 2}{19: }{22:y} |
- {14: 3}{19: }{22: } |
- {0:~ }|*3
- ## grid 3
- |
- ## grid 4
- {15:x }|
- {15:y }|
- {15: }|*2
- ]], float_pos={[4] = {1001, "NW", 1, 4, 10, true}}}
+ screen:expect({
+ grid = [[
+ ## grid 1
+ [2:----------------------------------------]|*6
+ [3:----------------------------------------]|
+ ## grid 2
+ {20: 1}{19: }{22:^x}{21: }|
+ {14: 2}{19: }{22:y} |
+ {14: 3}{19: }{22: } |
+ {0:~ }|*3
+ ## grid 3
+ |
+ ## grid 4
+ {15:x }|
+ {15:y }|
+ {15: }|*2
+ ]],
+ float_pos = { [4] = { 1001, "NW", 1, 4, 10, true, 50 } },
+ })
else
- screen:expect{grid=[[
+ screen:expect([[
{20: 1}{19: }{22:^x}{21: }|
{14: 2}{19: }{22:y} |
{14: 3}{19: }{22: } {15:x } |
{0:~ }{15:y }{0: }|
{0:~ }{15: }{0: }|*2
|
- ]]}
+ ]])
end
end)
@@ -2237,6 +2333,61 @@ describe('float window', function()
|
]]}
end
+
+ -- reuse before title pos
+ api.nvim_win_set_config(win, {title= 'new'})
+ if multigrid then
+ screen:expect({
+ grid = [[
+ ## grid 1
+ [2:----------------------------------------]|*6
+ [3:----------------------------------------]|
+ ## grid 2
+ ^ |
+ {0:~ }|*5
+ ## grid 3
+ |
+ ## grid 4
+ {5:╔══════}{11:new}{5:╗}|
+ {5:║}{1: halloj! }{5:║}|
+ {5:║}{1: BORDAA }{5:║}|
+ {5:╚═════════╝}|
+ ]],
+ float_pos = {
+ [4] = {1001, "NW", 1, 2, 5, true, 50};
+ },
+ win_viewport = {
+ [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0};
+ },
+ win_viewport_margins = {
+ [2] = {
+ bottom = 0,
+ left = 0,
+ right = 0,
+ top = 0,
+ win = 1000
+ },
+ [4] = {
+ bottom = 1,
+ left = 1,
+ right = 1,
+ top = 1,
+ win = 1001
+ }
+ },
+ })
+ else
+ screen:expect([[
+ ^ |
+ {0:~ }|
+ {0:~ }{5:╔══════}{11:new}{5:╗}{0: }|
+ {0:~ }{5:║}{1: halloj! }{5:║}{0: }|
+ {0:~ }{5:║}{1: BORDAA }{5:║}{0: }|
+ {0:~ }{5:╚═════════╝}{0: }|
+ |
+ ]])
+ end
end)
it('border with footer', function()
@@ -2382,6 +2533,61 @@ describe('float window', function()
|
]]}
end
+
+ -- reuse before footer pos
+ api.nvim_win_set_config(win, { footer = 'new' })
+ if multigrid then
+ screen:expect({
+ grid = [[
+ ## grid 1
+ [2:----------------------------------------]|*6
+ [3:----------------------------------------]|
+ ## grid 2
+ ^ |
+ {0:~ }|*5
+ ## grid 3
+ |
+ ## grid 4
+ {5:╔═════════╗}|
+ {5:║}{1: halloj! }{5:║}|
+ {5:║}{1: BORDAA }{5:║}|
+ {5:╚══════}{11:new}{5:╝}|
+ ]],
+ float_pos = {
+ [4] = {1001, "NW", 1, 2, 5, true, 50};
+ },
+ win_viewport = {
+ [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0};
+ },
+ win_viewport_margins = {
+ [2] = {
+ bottom = 0,
+ left = 0,
+ right = 0,
+ top = 0,
+ win = 1000
+ },
+ [4] = {
+ bottom = 1,
+ left = 1,
+ right = 1,
+ top = 1,
+ win = 1001
+ }
+ },
+ })
+ else
+ screen:expect([[
+ ^ |
+ {0:~ }|
+ {0:~ }{5:╔═════════╗}{0: }|
+ {0:~ }{5:║}{1: halloj! }{5:║}{0: }|
+ {0:~ }{5:║}{1: BORDAA }{5:║}{0: }|
+ {0:~ }{5:╚══════}{11:new}{5:╝}{0: }|
+ |
+ ]])
+ end
end)
it('border with title and footer', function()
@@ -8542,6 +8748,131 @@ describe('float window', function()
|
]]}
end
+
+ --
+ -- Check that floats are positioned correctly after changing the zindexes.
+ --
+ command('fclose')
+ exec_lua([[
+ local win1, win3 = ...
+ vim.api.nvim_win_set_config(win1, { zindex = 400, title = 'win_400', title_pos = 'center', border = 'double' })
+ vim.api.nvim_win_set_config(win3, { zindex = 300, title = 'win_300', title_pos = 'center', border = 'single' })
+ ]], win1, win3)
+ if multigrid then
+ screen:expect({
+ grid = [[
+ ## grid 1
+ [2:----------------------------------------]|*6
+ [3:----------------------------------------]|
+ ## grid 2
+ ^ |
+ {0:~ }|*5
+ ## grid 3
+ |
+ ## grid 4
+ {5:╔══════}{11:win_400}{5:═══════╗}|
+ {5:║}{7: }{5:║}|
+ {5:║}{7:~ }{5:║}|*2
+ {5:╚════════════════════╝}|
+ ## grid 6
+ {5:┌──────}{11:win_300}{5:───────┐}|
+ {5:│}{8: }{5:│}|
+ {5:│}{8:~ }{5:│}|*2
+ {5:└────────────────────┘}|
+ ]], float_pos={
+ [4] = {1001, "NW", 1, 1, 5, true, 400};
+ [6] = {1003, "NW", 1, 3, 7, true, 300};
+ }, win_viewport={
+ [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ [6] = {win = 1003, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ }, win_viewport_margins={
+ [2] = { bottom = 0, left = 0, right = 0, top = 0, win = 1000 },
+ [4] = { bottom = 1, left = 1, right = 1, top = 1, win = 1001 },
+ [6] = { bottom = 1, left = 1, right = 1, top = 1, win = 1003 }
+ }})
+ else
+ screen:expect({
+ grid = [[
+ ^ |
+ {0:~ }{5:╔══════}{11:win_400}{5:═══════╗}{0: }|
+ {0:~ }{5:║}{7: }{5:║─┐}{0: }|
+ {0:~ }{5:║}{7:~ }{5:║}{8: }{5:│}{0: }|*2
+ {0:~ }{5:╚════════════════════╝}{8: }{5:│}{0: }|
+ {5:└────────────────────┘} |
+ ]]
+ })
+ end
+ exec_lua([[
+ local win1, win3 = ...
+ vim.api.nvim_win_set_config(win1, { zindex = 100, title='win_100' })
+ vim.api.nvim_win_set_config(win3, { zindex = 150, title='win_150' })
+ ]], win1, win3)
+ if multigrid then
+ screen:expect({
+ grid = [[
+ ## grid 1
+ [2:----------------------------------------]|*6
+ [3:----------------------------------------]|
+ ## grid 2
+ ^ |
+ {0:~ }|*5
+ ## grid 3
+ |
+ ## grid 4
+ {5:╔══════}{11:win_100}{5:═══════╗}|
+ {5:║}{7: }{5:║}|
+ {5:║}{7:~ }{5:║}|*2
+ {5:╚════════════════════╝}|
+ ## grid 6
+ {5:┌──────}{11:win_150}{5:───────┐}|
+ {5:│}{8: }{5:│}|
+ {5:│}{8:~ }{5:│}|*2
+ {5:└────────────────────┘}|
+ ]],
+ float_pos = {
+ [4] = {1001, "NW", 1, 1, 5, true, 100};
+ [6] = {1003, "NW", 1, 3, 7, true, 150};
+ },
+ win_viewport = {
+ [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ [6] = {win = 1003, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ },
+ win_viewport_margins = {
+ [2] = {
+ bottom = 0,
+ left = 0,
+ right = 0,
+ top = 0,
+ win = 1000
+ },
+ [4] = {
+ bottom = 1,
+ left = 1,
+ right = 1,
+ top = 1,
+ win = 1001
+ },
+ [6] = {
+ bottom = 1,
+ left = 1,
+ right = 1,
+ top = 1,
+ win = 1003
+ }
+ },
+ })
+ else
+ screen:expect([[
+ ^ |
+ {0:~ }{5:╔═┌──────}{11:win_150}{5:───────┐}{0: }|
+ {0:~ }{5:║}{7: }{5:│}{8: }{5:│}{0: }|
+ {0:~ }{5:║}{7:~}{5:│}{8:~ }{5:│}{0: }|*2
+ {0:~ }{5:╚═└────────────────────┘}{0: }|
+ |
+ ]])
+ end
end)
it('can use winbar', function()
@@ -9523,4 +9854,3 @@ describe('float window', function()
with_ext_multigrid(false)
end)
end)
-
diff --git a/test/functional/ui/hlstate_spec.lua b/test/functional/ui/hlstate_spec.lua
index f8f5ee9488..e10c79fa48 100644
--- a/test/functional/ui/hlstate_spec.lua
+++ b/test/functional/ui/hlstate_spec.lua
@@ -224,10 +224,10 @@ describe('ext_hlstate detailed highlights', function()
[6] = { { foreground = tonumber('0x40ffff'), fg_indexed = true }, { 5, 1 } },
[7] = { {}, { { hi_name = 'MsgArea', ui_name = 'MsgArea', kind = 'ui' } } },
})
- command(("enew | call termopen(['%s'])"):format(testprg('tty-test')))
+ command(("enew | call jobstart(['%s'],{'term':v:true})"):format(testprg('tty-test')))
screen:expect([[
^tty ready |
- {1: } |
+ |
|*5
{7: }|
]])
@@ -242,7 +242,7 @@ describe('ext_hlstate detailed highlights', function()
screen:expect([[
^tty ready |
x {5:y z} |
- {1: } |
+ |
|*4
{7: }|
]])
@@ -250,7 +250,7 @@ describe('ext_hlstate detailed highlights', function()
screen:expect([[
^tty ready |
x {2:y }{3:z} |
- {1: } |
+ |
|*4
{7: }|
]])
@@ -268,7 +268,7 @@ describe('ext_hlstate detailed highlights', function()
else
screen:expect([[
^tty ready |
- x {4:y}{2: }{3:z} |
+ x {2:y }{3:z} |
|*5
{7: }|
]])
diff --git a/test/functional/ui/inccommand_user_spec.lua b/test/functional/ui/inccommand_user_spec.lua
index 2d26d2c5e0..3eee9a6e07 100644
--- a/test/functional/ui/inccommand_user_spec.lua
+++ b/test/functional/ui/inccommand_user_spec.lua
@@ -253,6 +253,50 @@ describe("'inccommand' for user commands", function()
]]
end)
+ it("can preview 'nomodifiable' buffer", function()
+ exec_lua([[
+ vim.api.nvim_create_user_command("PreviewTest", function() end, {
+ preview = function(ev)
+ vim.bo.modifiable = true
+ vim.api.nvim_buf_set_lines(0, 0, -1, false, {"cats"})
+ return 2
+ end,
+ })
+ ]])
+ command('set inccommand=split')
+
+ command('set nomodifiable')
+ eq(false, api.nvim_get_option_value('modifiable', { buf = 0 }))
+
+ feed(':PreviewTest')
+
+ screen:expect([[
+ cats |
+ {1:~ }|*8
+ {3:[No Name] [+] }|
+ |
+ {1:~ }|*4
+ {2:[Preview] }|
+ :PreviewTest^ |
+ ]])
+ feed('<Esc>')
+ screen:expect([[
+ text on line 1 |
+ more text on line 2 |
+ oh no, even more text |
+ will the text ever stop |
+ oh well |
+ did the text stop |
+ why won't it stop |
+ make the text stop |
+ ^ |
+ {1:~ }|*7
+ |
+ ]])
+
+ eq(false, api.nvim_get_option_value('modifiable', { buf = 0 }))
+ end)
+
it('works with inccommand=nosplit', function()
command('set inccommand=nosplit')
feed(':Replace text cats')
diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua
index 90e0b3e380..98312c42c9 100644
--- a/test/functional/ui/input_spec.lua
+++ b/test/functional/ui/input_spec.lua
@@ -368,7 +368,7 @@ describe('input non-printable chars', function()
"Xtest-overwrite" |
{9:WARNING: The file has been changed since reading it!!!} |
{6:Do you really want to write to it (y/n)?}u |
- {6:Do you really want to write to it (y/n)?} |
+ {6:Do you really want to write to it (y/n)?}{18:^E} |
{6:Do you really want to write to it (y/n)?}^ |
]])
@@ -379,7 +379,7 @@ describe('input non-printable chars', function()
"Xtest-overwrite" |
{9:WARNING: The file has been changed since reading it!!!} |
{6:Do you really want to write to it (y/n)?}u |
- {6:Do you really want to write to it (y/n)?} |
+ {6:Do you really want to write to it (y/n)?}{18:^E} |
{6:Do you really want to write to it (y/n)?}n |
{6:Press ENTER or type command to continue}^ |
]])
diff --git a/test/functional/ui/linematch_spec.lua b/test/functional/ui/linematch_spec.lua
index b564c01eaa..3593604c49 100644
--- a/test/functional/ui/linematch_spec.lua
+++ b/test/functional/ui/linematch_spec.lua
@@ -1147,4 +1147,32 @@ describe('regressions', function()
},
}
end)
+
+ -- oldtest: Test_linematch_3diffs_sanity_check()
+ it('sanity check with 3 diff buffers', function()
+ clear()
+ screen = Screen.new(75, 20)
+ n.api.nvim_buf_set_lines(0, 0, -1, false, { 'abcd', 'def', 'hij' })
+ n.exec('rightbelow vnew')
+ n.api.nvim_buf_set_lines(0, 0, -1, false, { 'defq', 'hijk', 'nopq' })
+ n.exec('rightbelow vnew')
+ n.api.nvim_buf_set_lines(0, 0, -1, false, { 'hijklm', 'nopqr', 'stuv' })
+ n.exec([[
+ set diffopt+=linematch:60
+ windo diffthis | wincmd t
+ call feedkeys("Aq\<esc>")
+ call feedkeys("GAklm\<esc>")
+ call feedkeys("o")
+ ]])
+ screen:expect([[
+ {7: }{22:abcdq }│{7: }{23:----------------------}│{7: }{23:-----------------------}|
+ {7: }{4:def }│{7: }{4:def}{27:q}{4: }│{7: }{23:-----------------------}|
+ {7: }{4:hijk}{27:lm}{4: }│{7: }{4:hijk }│{7: }{4:hijk}{27:lm}{4: }|
+ {7: }{23:----------------------}│{7: }{4:nopq }│{7: }{4:nopq}{27:r}{4: }|
+ {7: }{4:^ }│{7: }{23:----------------------}│{7: }{27:stuv}{4: }|
+ {1:~ }│{1:~ }│{1:~ }|*13
+ {3:[No Name] [+] }{2:[No Name] [+] [No Name] [+] }|
+ {5:-- INSERT --} |
+ ]])
+ end)
end)
diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua
index 734877d262..5c55dfe910 100644
--- a/test/functional/ui/messages_spec.lua
+++ b/test/functional/ui/messages_spec.lua
@@ -42,104 +42,130 @@ describe('ui/ext_messages', function()
it('msg_clear follows msg_show kind of confirm', function()
feed('iline 1<esc>')
feed(':call confirm("test")<cr>')
- screen:expect {
+ screen:expect({
grid = [[
- line ^1 |
- {1:~ }|*4
- ]],
+ line ^1 |
+ {1:~ }|*4
+ ]],
+ cmdline = {
+ {
+ content = { { '' } },
+ hl_id = 10,
+ pos = 0,
+ prompt = '[O]k: ',
+ },
+ },
messages = {
{
- content = { { '\ntest\n[O]k: ', 6, 11 } },
+ content = { { '\ntest\n', 6, 10 } },
+ history = false,
kind = 'confirm',
},
},
- }
-
+ })
feed('<cr>')
- screen:expect {
+ screen:expect({
grid = [[
- line ^1 |
- {1:~ }|*4
- ]],
- }
+ line ^1 |
+ {1:~ }|*4
+ ]],
+ cmdline = { { abort = false } },
+ })
end)
- it('msg_show kind=confirm,confirm_sub,emsg,wmsg,quickfix', function()
+ it('msg_show kinds', function()
feed('iline 1\nline 2<esc>')
- -- kind=confirm
+ -- confirm is now cmdline prompt
feed(':echo confirm("test")<cr>')
- screen:expect {
+ screen:expect({
grid = [[
- line 1 |
- line ^2 |
- {1:~ }|*3
- ]],
+ line 1 |
+ line ^2 |
+ {1:~ }|*3
+ ]],
+ cmdline = {
+ {
+ content = { { '' } },
+ hl_id = 10,
+ pos = 0,
+ prompt = '[O]k: ',
+ },
+ },
messages = {
{
- content = { { '\ntest\n[O]k: ', 6, 11 } },
+ content = { { '\ntest\n', 6, 10 } },
+ history = false,
kind = 'confirm',
},
},
- }
- feed('<cr><cr>')
- screen:expect {
+ })
+ feed('<cr>')
+ screen:expect({
grid = [[
- line 1 |
- line ^2 |
- {1:~ }|*3
- ]],
+ line 1 |
+ line ^2 |
+ {1:~ }|*3
+ ]],
+ cmdline = { { abort = false } },
messages = {
{
- content = { { '\ntest\n[O]k: ', 6, 11 } },
+ content = { { '\ntest\n', 6, 10 } },
+ history = false,
kind = 'confirm',
},
{
content = { { '1' } },
+ history = false,
kind = 'echo',
},
{
- content = { { 'Press ENTER or type command to continue', 6, 19 } },
+ content = { { 'Press ENTER or type command to continue', 6, 18 } },
+ history = false,
kind = 'return_prompt',
},
},
- }
- feed('<cr><cr>')
+ })
+ feed('<cr>')
- -- kind=confirm_sub
+ -- :substitute confirm is now cmdline prompt
feed(':%s/i/X/gc<cr>')
- screen:expect {
+ screen:expect({
grid = [[
- l{2:i}ne 1 |
- l{10:i}ne ^2 |
- {1:~ }|*3
- ]],
- messages = {
+ l{2:^i}ne 1 |
+ l{10:i}ne 2 |
+ {1:~ }|*3
+ ]],
+ cmdline = {
{
- content = { { 'replace with X (y/n/a/q/l/^E/^Y)?', 6, 19 } },
- kind = 'confirm_sub',
+ content = { { '' } },
+ hl_id = 18,
+ pos = 0,
+ prompt = 'replace with X? (y)es/(n)o/(a)ll/(q)uit/(l)ast/scroll up(^E)/down(^Y)',
},
},
- }
+ })
feed('nq')
-- kind=wmsg (editing readonly file)
command('write ' .. fname)
command('set readonly nohls')
feed('G$x')
- screen:expect {
+ screen:expect({
grid = [[
line 1 |
- line ^2 |
+ line^ |
{1:~ }|*3
]],
+ cmdline = { { abort = false } },
messages = {
{
- content = { { 'W10: Warning: Changing a readonly file', 19, 27 } },
+ content = { { 'W10: Warning: Changing a readonly file', 19, 26 } },
+ history = true,
kind = 'wmsg',
},
},
- }
+ })
-- kind=wmsg ('wrapscan' after search reaches EOF)
feed('uG$/i<cr>')
@@ -149,9 +175,11 @@ describe('ui/ext_messages', function()
line 2 |
{1:~ }|*3
]],
+ cmdline = { { abort = false } },
messages = {
{
- content = { { 'search hit BOTTOM, continuing at TOP', 19, 27 } },
+ content = { { 'search hit BOTTOM, continuing at TOP', 19, 26 } },
+ history = true,
kind = 'wmsg',
},
},
@@ -160,22 +188,21 @@ describe('ui/ext_messages', function()
-- kind=emsg after :throw
feed(':throw "foo"<cr>')
screen:expect {
- grid = [[
- l^ine 1 |
- line 2 |
- {1:~ }|*3
- ]],
+ cmdline = { { abort = false } },
messages = {
{
- content = { { 'Error detected while processing :', 9, 7 } },
+ content = { { 'Error detected while processing :', 9, 6 } },
+ history = true,
kind = 'emsg',
},
{
- content = { { 'E605: Exception not caught: foo', 9, 7 } },
- kind = '',
+ content = { { 'E605: Exception not caught: foo', 9, 6 } },
+ history = true,
+ kind = 'emsg',
},
{
- content = { { 'Press ENTER or type command to continue', 6, 19 } },
+ content = { { 'Press ENTER or type command to continue', 6, 18 } },
+ history = false,
kind = 'return_prompt',
},
},
@@ -191,13 +218,213 @@ describe('ui/ext_messages', function()
^line 2 |
{1:~ }|*3
]],
+ cmdline = { { abort = false } },
messages = {
{
content = { { '(2 of 2): line2' } },
+ history = true,
kind = 'quickfix',
},
},
}
+
+ -- search_cmd
+ feed('?line<cr>')
+ screen:expect({
+ grid = [[
+ ^line 1 |
+ line 2 |
+ {1:~ }|*3
+ ]],
+ cmdline = { { abort = false } },
+ messages = {
+ {
+ content = { { '?line ' } },
+ history = false,
+ kind = 'search_cmd',
+ },
+ },
+ })
+
+ -- highlight
+ feed(':filter character highlight<CR>')
+ screen:expect({
+ cmdline = { { abort = false } },
+ messages = {
+ {
+ content = {
+ { '\n@character ' },
+ { 'xxx', 26, 155 },
+ { ' ' },
+ { 'links to', 18, 5 },
+ { ' Character\n@character.special ' },
+ { 'xxx', 16, 156 },
+ { ' ' },
+ { 'links to', 18, 5 },
+ { ' SpecialChar' },
+ },
+ history = false,
+ kind = 'list_cmd',
+ },
+ },
+ })
+
+ -- undo
+ feed('uu')
+ screen:expect({
+ grid = [[
+ ^ |
+ {1:~ }|*4
+ ]],
+ messages = {
+ {
+ content = { { 'Already at oldest change' } },
+ history = true,
+ kind = 'undo',
+ },
+ },
+ })
+
+ feed('<C-r><C-r><C-r>')
+ screen:expect({
+ grid = [[
+ line 1 |
+ line^ |
+ {1:~ }|*3
+ ]],
+ messages = {
+ {
+ content = { { 'Already at newest change' } },
+ history = true,
+ kind = 'undo',
+ },
+ },
+ })
+
+ -- kind=completion
+ command('set noshowmode')
+ feed('i<C-n>')
+ screen:expect({
+ messages = {
+ {
+ content = { { 'The only match' } },
+ history = false,
+ kind = 'completion',
+ },
+ },
+ })
+ feed('<Esc>')
+ command('set showmode')
+
+ -- kind=echoerr for nvim_echo() err
+ feed(':call nvim_echo([["Error"], ["Message", "Special"]], 1, #{ err:1 })<CR>')
+ screen:expect({
+ cmdline = { { abort = false } },
+ messages = {
+ {
+ content = { { 'Error', 9, 6 }, { 'Message', 16, 99 } },
+ history = true,
+ kind = 'echoerr',
+ },
+ },
+ })
+
+ -- kind=verbose for nvim_echo() verbose
+ feed(':call nvim_echo([["Verbose Message"]], 1, #{ verbose:1 })<CR>')
+ screen:expect({
+ cmdline = { { abort = false } },
+ messages = {
+ {
+ content = { { 'Verbose Message' } },
+ history = true,
+ kind = 'verbose',
+ },
+ },
+ })
+
+ -- kind=verbose for :verbose messages
+ feed(':1verbose filter Diff[AC] hi<CR>')
+ screen:expect({
+ cmdline = { { abort = false } },
+ messages = {
+ {
+ content = {
+ { '\nDiffAdd ' },
+ { 'xxx', 22, 30 },
+ { ' ' },
+ { 'ctermbg=', 18, 5 },
+ { '81 ' },
+ { 'guibg=', 18, 5 },
+ { 'LightBlue' },
+ },
+ history = false,
+ kind = 'list_cmd',
+ },
+ {
+ content = { { '\n\tLast set from Lua (run Nvim with -V1 for more details)' } },
+ history = false,
+ kind = 'verbose',
+ },
+ {
+ content = {
+ { '\nDiffChange ' },
+ { 'xxx', 4, 31 },
+ { ' ' },
+ { 'ctermbg=', 18, 5 },
+ { '225 ' },
+ { 'guibg=', 18, 5 },
+ { 'LightMagenta' },
+ },
+ history = false,
+ kind = 'list_cmd',
+ },
+ {
+ content = { { '\n\tLast set from Lua (run Nvim with -V1 for more details)' } },
+ history = false,
+ kind = 'verbose',
+ },
+ {
+ content = { { 'Press ENTER or type command to continue', 6, 18 } },
+ history = false,
+ kind = 'return_prompt',
+ },
+ },
+ })
+
+ -- kind=shell for :!cmd messages
+ local cmd = t.is_os('win') and 'echo stdout& echo stderr>&2& exit 3'
+ or '{ echo stdout; echo stderr >&2; exit 3; }'
+ feed(('<CR>:!%s<CR>'):format(cmd))
+ screen:expect({
+ cmdline = { { abort = false } },
+ messages = {
+ {
+ content = { { (':!%s\r\n[No write since last change]\n'):format(cmd) } },
+ history = false,
+ kind = '',
+ },
+ {
+ content = { { ('stdout%s\n'):format(t.is_os('win') and '\r' or '') } },
+ history = false,
+ kind = 'shell_out',
+ },
+ {
+ content = { { ('stderr%s\n'):format(t.is_os('win') and '\r' or ''), 9, 6 } },
+ history = false,
+ kind = 'shell_err',
+ },
+ {
+ content = { { '\nshell returned 3\n\n' } },
+ history = false,
+ kind = 'shell_ret',
+ },
+ {
+ content = { { 'Press ENTER or type command to continue', 6, 18 } },
+ history = false,
+ kind = 'return_prompt',
+ },
+ },
+ })
end)
it(':echoerr', function()
@@ -207,10 +434,14 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
- messages = { {
- content = { { 'raa', 9, 7 } },
- kind = 'echoerr',
- } },
+ cmdline = { { abort = false } },
+ messages = {
+ {
+ content = { { 'raa', 9, 6 } },
+ history = true,
+ kind = 'echoerr',
+ },
+ },
}
-- cmdline in a later input cycle clears error message
@@ -233,17 +464,21 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
+ cmdline = { { abort = false } },
messages = {
{
- content = { { 'bork', 9, 7 } },
+ content = { { 'bork', 9, 6 } },
+ history = true,
kind = 'echoerr',
},
{
- content = { { 'fail', 9, 7 } },
+ content = { { 'fail', 9, 6 } },
+ history = true,
kind = 'echoerr',
},
{
- content = { { 'Press ENTER or type command to continue', 6, 19 } },
+ content = { { 'Press ENTER or type command to continue', 6, 18 } },
+ history = false,
kind = 'return_prompt',
},
},
@@ -255,21 +490,26 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
+ cmdline = { { abort = false } },
messages = {
{
- content = { { 'bork', 9, 7 } },
+ content = { { 'bork', 9, 6 } },
+ history = true,
kind = 'echoerr',
},
{
- content = { { 'fail', 9, 7 } },
+ content = { { 'fail', 9, 6 } },
+ history = true,
kind = 'echoerr',
},
{
- content = { { 'extrafail', 9, 7 } },
+ content = { { 'extrafail', 9, 6 } },
+ history = true,
kind = 'echoerr',
},
{
- content = { { 'Press ENTER or type command to continue', 6, 19 } },
+ content = { { 'Press ENTER or type command to continue', 6, 18 } },
+ history = false,
kind = 'return_prompt',
},
},
@@ -290,13 +530,17 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
- messages = { {
- content = { { 'problem', 9, 7 } },
- kind = 'echoerr',
- } },
+ messages = {
+ {
+ content = { { 'problem', 9, 6 } },
+ history = true,
+ kind = 'echoerr',
+ },
+ },
cmdline = {
{
prompt = 'foo> ',
+ hl_id = 0,
content = { { '' } },
pos = 0,
},
@@ -309,6 +553,7 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
+ cmdline = { { abort = false } },
}
eq('solution', eval('x'))
@@ -318,16 +563,18 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
+ cmdline = { { abort = false } },
msg_history = {
- { kind = 'echoerr', content = { { 'raa', 9, 7 } } },
- { kind = 'echoerr', content = { { 'bork', 9, 7 } } },
- { kind = 'echoerr', content = { { 'fail', 9, 7 } } },
- { kind = 'echoerr', content = { { 'extrafail', 9, 7 } } },
- { kind = 'echoerr', content = { { 'problem', 9, 7 } } },
+ { kind = 'echoerr', content = { { 'raa', 9, 6 } } },
+ { kind = 'echoerr', content = { { 'bork', 9, 6 } } },
+ { kind = 'echoerr', content = { { 'fail', 9, 6 } } },
+ { kind = 'echoerr', content = { { 'extrafail', 9, 6 } } },
+ { kind = 'echoerr', content = { { 'problem', 9, 6 } } },
},
messages = {
{
- content = { { 'Press ENTER or type command to continue', 6, 19 } },
+ content = { { 'Press ENTER or type command to continue', 6, 18 } },
+ history = false,
kind = 'return_prompt',
},
},
@@ -350,9 +597,11 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
+ cmdline = { { abort = false } },
messages = {
{
- content = { { 'bork\nfail', 9, 7 } },
+ content = { { 'bork\nfail', 9, 6 } },
+ history = true,
kind = 'echoerr',
},
},
@@ -364,15 +613,17 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
+ cmdline = { { abort = false } },
messages = {
{
- content = { { 'Press ENTER or type command to continue', 6, 19 } },
+ content = { { 'Press ENTER or type command to continue', 6, 18 } },
+ history = false,
kind = 'return_prompt',
},
},
msg_history = {
{
- content = { { 'bork\nfail', 9, 7 } },
+ content = { { 'bork\nfail', 9, 6 } },
kind = 'echoerr',
},
},
@@ -390,8 +641,9 @@ describe('ui/ext_messages', function()
{10:line} 2 |
{1:~ }|*3
]],
+ cmdline = { { abort = false } },
messages = {
- { content = { { '/line W [1/2]' } }, kind = 'search_count' },
+ { content = { { '/line W [1/2]' } }, kind = 'search_count', history = false },
},
}
@@ -403,35 +655,7 @@ describe('ui/ext_messages', function()
{1:~ }|*3
]],
messages = {
- { content = { { '/line [2/2]' } }, kind = 'search_count' },
- },
- }
- end)
-
- it(':hi Group output', function()
- feed(':hi ErrorMsg<cr>')
- screen:expect {
- grid = [[
- ^ |
- {1:~ }|*4
- ]],
- messages = {
- {
- content = {
- { '\nErrorMsg ' },
- { 'xxx', 9, 7 },
- { ' ' },
- { 'ctermfg=', 18, 6 },
- { '15 ' },
- { 'ctermbg=', 18, 6 },
- { '1 ' },
- { 'guifg=', 18, 6 },
- { 'White ' },
- { 'guibg=', 18, 6 },
- { 'Red' },
- },
- kind = '',
- },
+ { content = { { '/line [2/2]' } }, kind = 'search_count', history = false },
},
}
end)
@@ -444,11 +668,13 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
+ cmdline = { { abort = false } },
messages = {
- { content = { { 'x #1' } }, kind = '' },
- { content = { { 'y #2' } }, kind = '' },
+ { content = { { 'x #1' } }, kind = 'list_cmd', history = false },
+ { content = { { 'y #2' } }, kind = 'list_cmd', history = false },
{
- content = { { 'Press ENTER or type command to continue', 6, 19 } },
+ content = { { 'Press ENTER or type command to continue', 6, 18 } },
+ history = false,
kind = 'return_prompt',
},
},
@@ -463,7 +689,7 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
- showmode = { { '-- INSERT --', 5, 12 } },
+ showmode = { { '-- INSERT --', 5, 11 } },
}
feed('alphpabet<cr>alphanum<cr>')
@@ -474,7 +700,7 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*2
]],
- showmode = { { '-- INSERT --', 5, 12 } },
+ showmode = { { '-- INSERT --', 5, 11 } },
}
feed('<c-x>')
@@ -485,7 +711,7 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*2
]],
- showmode = { { '-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)', 5, 12 } },
+ showmode = { { '-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)', 5, 11 } },
}
feed('<c-p>')
@@ -501,7 +727,7 @@ describe('ui/ext_messages', function()
items = { { 'alphpabet', '', '', '' }, { 'alphanum', '', '', '' } },
pos = 1,
},
- showmode = { { '-- Keyword Local completion (^N^P) ', 5, 12 }, { 'match 1 of 2', 6, 19 } },
+ showmode = { { '-- Keyword Local completion (^N^P) ', 5, 11 }, { 'match 1 of 2', 6, 18 } },
}
-- echomsg and showmode don't overwrite each other, this is the same
@@ -519,11 +745,14 @@ describe('ui/ext_messages', function()
items = { { 'alphpabet', '', '', '' }, { 'alphanum', '', '', '' } },
pos = 1,
},
- messages = { {
- content = { { 'stuff' } },
- kind = 'echomsg',
- } },
- showmode = { { '-- Keyword Local completion (^N^P) ', 5, 12 }, { 'match 1 of 2', 6, 19 } },
+ messages = {
+ {
+ content = { { 'stuff' } },
+ history = true,
+ kind = 'echomsg',
+ },
+ },
+ showmode = { { '-- Keyword Local completion (^N^P) ', 5, 11 }, { 'match 1 of 2', 6, 18 } },
}
feed('<c-p>')
@@ -539,11 +768,14 @@ describe('ui/ext_messages', function()
items = { { 'alphpabet', '', '', '' }, { 'alphanum', '', '', '' } },
pos = 0,
},
- messages = { {
- content = { { 'stuff' } },
- kind = 'echomsg',
- } },
- showmode = { { '-- Keyword Local completion (^N^P) ', 5, 12 }, { 'match 2 of 2', 6, 19 } },
+ messages = {
+ {
+ content = { { 'stuff' } },
+ history = true,
+ kind = 'echomsg',
+ },
+ },
+ showmode = { { '-- Keyword Local completion (^N^P) ', 5, 11 }, { 'match 2 of 2', 6, 18 } },
}
feed('<esc>:messages<cr>')
@@ -554,13 +786,15 @@ describe('ui/ext_messages', function()
alphpabe^t |
{1:~ }|*2
]],
+ cmdline = { { abort = false } },
msg_history = { {
content = { { 'stuff' } },
kind = 'echomsg',
} },
messages = {
{
- content = { { 'Press ENTER or type command to continue', 6, 19 } },
+ content = { { 'Press ENTER or type command to continue', 6, 18 } },
+ history = false,
kind = 'return_prompt',
},
},
@@ -574,7 +808,7 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
- showmode = { { 'recording @q', 5, 12 } },
+ showmode = { { 'recording @q', 5, 11 } },
}
feed('i')
@@ -583,7 +817,7 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
- showmode = { { '-- INSERT --recording @q', 5, 12 } },
+ showmode = { { '-- INSERT --recording @q', 5, 11 } },
}
feed('<esc>')
@@ -592,7 +826,7 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
- showmode = { { 'recording @q', 5, 12 } },
+ showmode = { { 'recording @q', 5, 11 } },
}
feed('q')
@@ -611,7 +845,7 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
- showmode = { { 'recording @q', 5, 12 } },
+ showmode = { { 'recording @q', 5, 11 } },
mode = 'normal',
}
@@ -621,7 +855,7 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
- showmode = { { 'recording @q', 5, 12 } },
+ showmode = { { 'recording @q', 5, 11 } },
mode = 'insert',
}
@@ -631,7 +865,7 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
- showmode = { { 'recording @q', 5, 12 } },
+ showmode = { { 'recording @q', 5, 11 } },
mode = 'normal',
}
@@ -653,7 +887,7 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
- ruler = { { '0,0-1 All', 9, 62 } },
+ ruler = { { '0,0-1 All', 9, 61 } },
})
command('hi clear MsgArea')
feed('i')
@@ -662,7 +896,7 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
- showmode = { { '-- INSERT --', 5, 12 } },
+ showmode = { { '-- INSERT --', 5, 11 } },
ruler = { { '0,1 All' } },
}
feed('abcde<cr>12345<esc>')
@@ -700,7 +934,7 @@ describe('ui/ext_messages', function()
{17:123}45 |
{1:~ }|*3
]],
- showmode = { { '-- VISUAL BLOCK --', 5, 12 } },
+ showmode = { { '-- VISUAL BLOCK --', 5, 11 } },
showcmd = { { '2x3' } },
ruler = { { '1,3 All' } },
})
@@ -752,10 +986,14 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
- messages = { {
- content = { { 'howdy' } },
- kind = 'echomsg',
- } },
+ cmdline = { { abort = false } },
+ messages = {
+ {
+ content = { { 'howdy' } },
+ history = true,
+ kind = 'echomsg',
+ },
+ },
}
-- always test a message without kind. If this one gets promoted to a
@@ -769,6 +1007,7 @@ describe('ui/ext_messages', function()
messages = {
{
content = { { 'Type :qa and press <Enter> to exit Nvim' } },
+ history = true,
kind = '',
},
},
@@ -780,10 +1019,14 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
- messages = { {
- content = { { 'bork', 9, 7 } },
- kind = 'echoerr',
- } },
+ cmdline = { { abort = false } },
+ messages = {
+ {
+ content = { { 'bork', 9, 6 } },
+ history = true,
+ kind = 'echoerr',
+ },
+ },
}
feed(':echo "xyz"<cr>')
@@ -792,10 +1035,14 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
- messages = { {
- content = { { 'xyz' } },
- kind = 'echo',
- } },
+ cmdline = { { abort = false } },
+ messages = {
+ {
+ content = { { 'xyz' } },
+ history = false,
+ kind = 'echo',
+ },
+ },
}
feed(':call nosuchfunction()<cr>')
@@ -804,9 +1051,11 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
+ cmdline = { { abort = false } },
messages = {
{
- content = { { 'E117: Unknown function: nosuchfunction', 9, 7 } },
+ content = { { 'E117: Unknown function: nosuchfunction', 9, 6 } },
+ history = true,
kind = 'emsg',
},
},
@@ -818,15 +1067,17 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
+ cmdline = { { abort = false } },
msg_history = {
{ kind = 'echomsg', content = { { 'howdy' } } },
{ kind = '', content = { { 'Type :qa and press <Enter> to exit Nvim' } } },
- { kind = 'echoerr', content = { { 'bork', 9, 7 } } },
- { kind = 'emsg', content = { { 'E117: Unknown function: nosuchfunction', 9, 7 } } },
+ { kind = 'echoerr', content = { { 'bork', 9, 6 } } },
+ { kind = 'emsg', content = { { 'E117: Unknown function: nosuchfunction', 9, 6 } } },
},
messages = {
{
- content = { { 'Press ENTER or type command to continue', 6, 19 } },
+ content = { { 'Press ENTER or type command to continue', 6, 18 } },
+ history = false,
kind = 'return_prompt',
},
},
@@ -851,11 +1102,14 @@ describe('ui/ext_messages', function()
}
feed('<cr>')
- screen:expect([[
- ^ |
- {1:~ }|*3
- |
- ]])
+ screen:expect({
+ grid = [[
+ ^ |
+ {1:~ }|*3
+ |
+ ]],
+ cmdline = { { abort = false } },
+ })
eq(1, eval('&cmdheight'))
feed(':set cmdheight=0')
@@ -874,10 +1128,13 @@ describe('ui/ext_messages', function()
},
}
feed('<cr>')
- screen:expect([[
- ^ |
- {1:~ }|*4
- ]])
+ screen:expect({
+ grid = [[
+ ^ |
+ {1:~ }|*4
+ ]],
+ cmdline = { { abort = false } },
+ })
eq(0, eval('&cmdheight'))
end)
@@ -888,6 +1145,7 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
+ cmdline = { { abort = false } },
messages = {
{
content = {
@@ -899,9 +1157,10 @@ stack traceback:
[C]: in function 'error'
[string ":lua"]:1: in main chunk]],
9,
- 7,
+ 6,
},
},
+ history = true,
kind = 'lua_error',
},
},
@@ -916,11 +1175,13 @@ stack traceback:
^ |
{1:~ }|*4
]],
+ cmdline = { { abort = false } },
messages = {
{
content = {
- { "Error invoking 'test_method' on channel 1:\ncomplete\nerror\n\nmessage", 9, 7 },
+ { "Error invoking 'test_method' on channel 1:\ncomplete\nerror\n\nmessage", 9, 6 },
},
+ history = true,
kind = 'rpc_error',
},
},
@@ -940,6 +1201,7 @@ stack traceback:
feed(':map<cr>')
screen:expect {
+ cmdline = { { abort = false } },
messages = {
{
content = {
@@ -947,7 +1209,8 @@ stack traceback:
{ '*', 18, 1 },
{ ' k' },
},
- kind = '',
+ history = false,
+ kind = 'list_cmd',
},
},
}
@@ -964,10 +1227,13 @@ stack traceback:
^ |
{1:~ }|*6
]],
- messages = { {
- content = { { 'wildmenu wildmode' } },
- kind = '',
- } },
+ messages = {
+ {
+ content = { { 'wildmenu wildmode\n' } },
+ history = false,
+ kind = 'wildlist',
+ },
+ },
cmdline = {
{
firstc = ':',
@@ -983,51 +1249,94 @@ stack traceback:
feed('ihelllo<esc>')
feed('z=')
- screen:expect {
+ screen:expect({
grid = [[
- {100:helllo} |
- {1:~ }|*3
- {1:^~ }|
- ]],
+ {100:^helllo} |
+ {1:~ }|*4
+ ]],
+ cmdline = {
+ {
+ content = { { '' } },
+ hl_id = 0,
+ pos = 0,
+ prompt = 'Type number and <Enter> or click with the mouse (q or empty cancels): ',
+ },
+ },
messages = {
{
- content = {
- {
- 'Change "helllo" to:\n 1 "Hello"\n 2 "Hallo"\n 3 "Hullo"\nType number and <Enter> or click with the mouse (q or empty cancels): ',
- },
- },
- kind = '',
+ content = { { 'Change "helllo" to:\n 1 "Hello"\n 2 "Hallo"\n 3 "Hullo"\n' } },
+ history = false,
+ kind = 'list_cmd',
},
},
- }
+ })
feed('1')
- screen:expect {
+ screen:expect({
grid = [[
- {100:helllo} |
- {1:~ }|*3
- {1:^~ }|
- ]],
+ {100:^helllo} |
+ {1:~ }|*4
+ ]],
+ cmdline = {
+ {
+ content = { { '1' } },
+ hl_id = 0,
+ pos = 1,
+ prompt = 'Type number and <Enter> or click with the mouse (q or empty cancels): ',
+ },
+ },
messages = {
{
- content = {
- {
- 'Change "helllo" to:\n 1 "Hello"\n 2 "Hallo"\n 3 "Hullo"\nType number and <Enter> or click with the mouse (q or empty cancels): ',
- },
- },
- kind = '',
+ content = { { 'Change "helllo" to:\n 1 "Hello"\n 2 "Hallo"\n 3 "Hullo"\n' } },
+ history = false,
+ kind = 'list_cmd',
},
- { content = { { '1' } }, kind = '' },
},
- }
+ })
feed('<cr>')
- screen:expect {
+ screen:expect({
grid = [[
- ^Hello |
- {1:~ }|*4
- ]],
- }
+ ^Hello |
+ {1:~ }|*4
+ ]],
+ cmdline = { { abort = false } },
+ })
+
+ async_meths.nvim_command("let g:n = inputlist(['input0', 'input1'])")
+ screen:expect({
+ grid = [[
+ ^Hello |
+ {1:~ }|*4
+ ]],
+ cmdline = {
+ {
+ content = { { '' } },
+ hl_id = 0,
+ pos = 0,
+ prompt = 'Type number and <Enter> or click with the mouse (q or empty cancels): ',
+ },
+ },
+ messages = {
+ {
+ content = { { 'input0\ninput1\n' } },
+ history = false,
+ kind = 'list_cmd',
+ },
+ },
+ })
+
+ feed('42<CR>')
+ screen:expect({
+ grid = [[
+ ^Hello |
+ {1:~ }|*4
+ ]],
+ cmdline = { {
+ abort = false,
+ } },
+ })
+ eq(42, eval('g:n'))
end)
it('supports nvim_echo messages with multiple attrs', function()
@@ -1043,7 +1352,8 @@ stack traceback:
]],
messages = {
{
- content = { { 'wow, ', 10, 9 }, { 'such\n\nvery ', 9, 7 }, { 'color', 8, 13 } },
+ content = { { 'wow, ', 10, 8 }, { 'such\n\nvery ', 9, 6 }, { 'color', 8, 12 } },
+ history = true,
kind = 'echomsg',
},
},
@@ -1055,8 +1365,13 @@ stack traceback:
^ |
{1:~ }|*4
]],
+ cmdline = { { abort = false } },
messages = {
- { content = { { '\n 1 %a "[No Name]" line 1' } }, kind = '' },
+ {
+ content = { { '\n 1 %a "[No Name]" line 1' } },
+ kind = 'list_cmd',
+ history = false,
+ },
},
}
@@ -1066,15 +1381,17 @@ stack traceback:
^ |
{1:~ }|*4
]],
+ cmdline = { { abort = false } },
messages = {
{
- content = { { 'Press ENTER or type command to continue', 6, 19 } },
+ content = { { 'Press ENTER or type command to continue', 6, 18 } },
+ history = false,
kind = 'return_prompt',
},
},
msg_history = {
{
- content = { { 'wow, ', 10, 9 }, { 'such\n\nvery ', 9, 7 }, { 'color', 8, 13 } },
+ content = { { 'wow, ', 10, 8 }, { 'such\n\nvery ', 9, 6 }, { 'color', 8, 12 } },
kind = 'echomsg',
},
},
@@ -1093,7 +1410,11 @@ stack traceback:
command('write ' .. fname)
screen:expect({
messages = {
- { content = { { string.format('"%s" [New] 0L, 0B written', fname) } }, kind = '' },
+ {
+ content = { { string.format('"%s" [New] 0L, 0B written', fname) } },
+ kind = 'bufwrite',
+ history = true,
+ },
},
})
end)
@@ -1105,13 +1426,25 @@ stack traceback:
screen_showmode(...)
showmode = showmode + 1
end
+ local s1 = [[
+ ^ |
+ {1:~ }|*4
+ ]]
+ screen:expect(s1)
+ eq(showmode, 0)
+ feed('i')
screen:expect({
- grid = [[
- ^ |
- {1:~ }|*4
- ]],
+ grid = s1,
+ showmode = { { '-- INSERT --', 5, 11 } },
})
- eq(showmode, 1)
+ eq(showmode, 2)
+ command('set noshowmode')
+ feed('<Esc>')
+ screen:expect(s1)
+ eq(showmode, 3)
+ feed('i')
+ screen:expect_unchanged()
+ eq(showmode, 3)
end)
it('emits single message for multiline print())', function()
@@ -1120,6 +1453,7 @@ stack traceback:
messages = {
{
content = { { 'foo\nbar\nbaz' } },
+ history = true,
kind = 'lua_print',
},
},
@@ -1133,6 +1467,7 @@ stack traceback:
messages = {
{
content = { { '{\n foo = "bar"\n}' } },
+ history = true,
kind = 'lua_print',
},
},
@@ -1140,6 +1475,36 @@ stack traceback:
exec_lua([[vim.print({ foo = "bar" })]])
screen:expect_unchanged()
end)
+
+ it('ruler redraw does not crash due to double grid_line_start()', function()
+ exec_lua([[
+ local ns = vim.api.nvim_create_namespace('')
+ vim.ui_attach(ns, { ext_messages = true }, function(event, ...)
+ if event == 'msg_ruler' then
+ vim.api.nvim__redraw({ flush = true })
+ end
+ end)
+ vim.o.ruler = true
+ vim.o.laststatus = 0
+ ]])
+ feed('i')
+ n.assert_alive()
+ end)
+
+ it(':digraph contains newlines', function()
+ command('digraph')
+ screen:expect({
+ condition = function()
+ local nl = 0
+ eq('list_cmd', screen.messages[1].kind)
+ for _, chunk in ipairs(screen.messages[1].content) do
+ nl = nl + (chunk[2]:find('\n') and 1 or 0)
+ end
+ eq(682, nl)
+ screen.messages = {}
+ end,
+ })
+ end)
end)
describe('ui/builtin messages', function()
@@ -1719,7 +2084,7 @@ describe('ui/ext_messages', function()
{1:~ }type :help iccf{18:<Enter>} for information {1: }|
{1:~ }|*5
]]
- local showmode = { { '-- INSERT --', 5, 12 } }
+ local showmode = { { '-- INSERT --', 5, 11 } }
screen:expect(introscreen)
-- <c-l> (same as :mode) does _not_ clear intro message
@@ -1792,9 +2157,11 @@ describe('ui/ext_messages', function()
type :help iccf{18:<Enter>} for information |
|*5
]],
+ cmdline = { { abort = false } },
messages = {
{
- content = { { 'Press ENTER or type command to continue', 6, 19 } },
+ content = { { 'Press ENTER or type command to continue', 6, 18 } },
+ history = false,
kind = 'return_prompt',
},
},
@@ -1874,8 +2241,9 @@ describe('ui/ext_messages', function()
{1:~ }|*10
{3:[No Name] }|
]],
+ cmdline = { { abort = false } },
messages = {
- { content = { { ' cmdheight=0' } }, kind = '' },
+ { content = { { ' cmdheight=0' } }, kind = 'list_cmd', history = false },
},
})
@@ -1890,8 +2258,9 @@ describe('ui/ext_messages', function()
{1:~ }|*9
{3:[No Name] }|
]],
+ cmdline = { { abort = false } },
messages = {
- { content = { { ' laststatus=3' } }, kind = '' },
+ { content = { { ' laststatus=3' } }, kind = 'list_cmd', history = false },
},
})
@@ -1910,8 +2279,9 @@ describe('ui/ext_messages', function()
{1:~ }|*10
{3:[No Name] }|
]],
+ cmdline = { { abort = false } },
messages = {
- { content = { { ' cmdheight=0' } }, kind = '' },
+ { content = { { ' cmdheight=0' } }, kind = 'list_cmd', history = false },
},
})
end)
@@ -2015,7 +2385,7 @@ describe('ui/msg_puts_printf', function()
)
cmd = cmd .. '"' .. nvim_prog .. '" -u NONE -i NONE -Es -V1'
- command([[call termopen(']] .. cmd .. [[')]])
+ command([[call jobstart(']] .. cmd .. [[',{'term':v:true})]])
screen:expect([[
^Exモードに入ります。ノー |
マルモードに戻るには "vis|
diff --git a/test/functional/ui/mode_spec.lua b/test/functional/ui/mode_spec.lua
index 8c6a284cd6..01f4dda227 100644
--- a/test/functional/ui/mode_spec.lua
+++ b/test/functional/ui/mode_spec.lua
@@ -94,6 +94,46 @@ describe('ui mode_change event', function()
}
end)
+ -- oldtest: Test_mouse_shape_indent_norm_with_gq()
+ it('is restored to Normal mode after "gq" indents using :normal #12309', function()
+ screen:try_resize(60, 6)
+ n.exec([[
+ func Indent()
+ exe "normal! \<Ignore>"
+ return 0
+ endfunc
+
+ setlocal indentexpr=Indent()
+ call setline(1, [repeat('a', 80), repeat('b', 80)])
+ ]])
+
+ feed('ggVG')
+ screen:expect {
+ grid = [[
+ {17:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
+ {17:aaaaaaaaaaaaaaaaaaaa} |
+ ^b{17:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb}|
+ {17:bbbbbbbbbbbbbbbbbbbb} |
+ {1:~ }|
+ {5:-- VISUAL LINE --} |
+ ]],
+ mode = 'visual',
+ }
+
+ feed('gq')
+ screen:expect {
+ grid = [[
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ aaaaaaaaaaaaaaaaaaaa |
+ ^bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|
+ bbbbbbbbbbbbbbbbbbbb |
+ {1:~ }|
+ |
+ ]],
+ mode = 'normal',
+ }
+ end)
+
it('works in insert mode', function()
feed('i')
screen:expect {
diff --git a/test/functional/ui/multigrid_spec.lua b/test/functional/ui/multigrid_spec.lua
index 3afda0c4af..cac7174cb6 100644
--- a/test/functional/ui/multigrid_spec.lua
+++ b/test/functional/ui/multigrid_spec.lua
@@ -1094,7 +1094,7 @@ describe('ext_multigrid', function()
end)
it('supports mouse', function()
- command('autocmd! nvim_popupmenu') -- Delete the default MenuPopup event handler.
+ command('autocmd! nvim.popupmenu') -- Delete the default MenuPopup event handler.
insert('some text\nto be clicked')
screen:expect{grid=[[
## grid 1
diff --git a/test/functional/ui/output_spec.lua b/test/functional/ui/output_spec.lua
index b5a09d814c..37e0e1344b 100644
--- a/test/functional/ui/output_spec.lua
+++ b/test/functional/ui/output_spec.lua
@@ -34,7 +34,7 @@ describe('shell command :!', function()
n.nvim_set .. ' notermguicolors',
})
screen:expect([[
- {1: } |
+ ^ |
{4:~ }|*4
|
{3:-- TERMINAL --} |
@@ -78,7 +78,7 @@ describe('shell command :!', function()
29999: foo |
30000: foo |
|
- {10:Press ENTER or type command to continue}{1: } |
+ {10:Press ENTER or type command to continue}^ |
{3:-- TERMINAL --} |
]],
{
diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua
index 8fe8975b4a..4c5b1d2bd2 100644
--- a/test/functional/ui/popupmenu_spec.lua
+++ b/test/functional/ui/popupmenu_spec.lua
@@ -841,7 +841,7 @@ describe('ui/ext_popupmenu', function()
aunmenu PopUp
" Delete the default MenuPopup event handler.
- autocmd! nvim_popupmenu
+ autocmd! nvim.popupmenu
menu PopUp.foo :let g:menustr = 'foo'<CR>
menu PopUp.bar :let g:menustr = 'bar'<CR>
menu PopUp.baz :let g:menustr = 'baz'<CR>
@@ -1162,6 +1162,8 @@ describe('builtin popupmenu', function()
[6] = { foreground = Screen.colors.White, background = Screen.colors.Red },
[7] = { background = Screen.colors.Yellow }, -- Search
[8] = { foreground = Screen.colors.Red },
+ [9] = { foreground = Screen.colors.Yellow, background = Screen.colors.Green },
+ [10] = { foreground = Screen.colors.White, background = Screen.colors.Green },
ks = { foreground = Screen.colors.Red, background = Screen.colors.Grey },
kn = { foreground = Screen.colors.Red, background = Screen.colors.Plum1 },
xs = { foreground = Screen.colors.Black, background = Screen.colors.Grey },
@@ -1542,6 +1544,81 @@ describe('builtin popupmenu', function()
end)
if not multigrid then
+ describe('popup and preview window do not overlap', function()
+ before_each(function()
+ screen:try_resize(53, 20)
+ end)
+
+ -- oldtest: Test_popup_and_previewwindow_dump_pedit()
+ it('with :pedit', function()
+ exec([[
+ set previewheight=9
+ silent! pedit
+ call setline(1, map(repeat(["ab"], 10), "v:val .. v:key"))
+ exec "norm! G\<C-E>\<C-E>"
+ ]])
+ feed('o')
+ n.poke_eventloop()
+ feed('<C-X><C-N>')
+ screen:expect([[
+ ab0 |
+ ab1 |
+ ab2 |
+ ab3 |
+ ab4 |
+ ab5 |
+ ab6 |
+ ab7 |
+ ab8 |
+ {s:ab0 }{c: }{3:ew][+] }|
+ {n:ab1 }{c: } |
+ {n:ab2 }{c: } |
+ {n:ab3 }{c: } |
+ {n:ab4 }{s: } |
+ {n:ab5 }{s: } |
+ {n:ab6 }{s: } |
+ ab0^ |
+ {1:~ }|
+ {4:[No Name] [+] }|
+ {2:-- Keyword Local completion (^N^P) }{5:match 1 of 10} |
+ ]])
+ end)
+
+ -- oldtest: Test_popup_and_previewwindow_dump_pbuffer()
+ it('with :pbuffer', function()
+ exec([[
+ set previewheight=9
+ silent! pbuffer
+ call setline(1, map(repeat(["ab"], 10), "v:val .. v:key"))
+ exec "norm! G\<C-E>\<C-E>\<C-E>"
+ ]])
+ feed('o')
+ n.poke_eventloop()
+ feed('<C-X><C-N>')
+ screen:expect([[
+ ab0 |
+ ab1 |
+ ab2 |
+ ab3 |
+ ab4 |
+ ab5 |
+ ab6 |
+ ab7 |
+ ab8 |
+ {s:ab0 }{c: }{3:ew][+] }|
+ {n:ab1 }{c: } |
+ {n:ab2 }{c: } |
+ {n:ab3 }{s: } |
+ {n:ab4 }{s: } |
+ {n:ab5 }{s: } |
+ ab0^ |
+ {1:~ }|*2
+ {4:[No Name] [+] }|
+ {2:-- Keyword Local completion (^N^P) }{5:match 1 of 10} |
+ ]])
+ end)
+ end)
+
-- oldtest: Test_pum_with_preview_win()
it('preview window opened during completion', function()
exec([[
@@ -1603,7 +1680,7 @@ describe('builtin popupmenu', function()
end)
end
- describe('floating window preview #popup', function()
+ describe('floating window preview popup', function()
it('pum popup preview', function()
--row must > 10
screen:try_resize(40, 11)
@@ -1616,14 +1693,29 @@ describe('builtin popupmenu', function()
endfunc
set omnifunc=Omni_test
set completeopt=menu,popup
-
funct Set_info()
let comp_info = complete_info()
if comp_info['selected'] == 2
call nvim__complete_set(comp_info['selected'], {"info": "3info"})
endif
endfunc
- autocmd CompleteChanged * call Set_info()
+ funct TsHl()
+ let comp_info = complete_info()
+ if get(comp_info, 'previewbufnr', 0) > 0
+ call v:lua.vim.treesitter.start(comp_info['preview_bufnr'], 'markdown')
+ endif
+ if comp_info['selected'] == 0
+ call nvim__complete_set(comp_info['selected'], {"info": "```lua\nfunction test()\n print('foo')\nend\n```"})
+ endif
+ endfunc
+ augroup Group
+ au!
+ autocmd CompleteChanged * :call Set_info()
+ augroup END
+ funct TestTs()
+ autocmd! Group
+ autocmd CompleteChanged * call TsHl()
+ endfunc
]])
feed('Gi<C-x><C-o>')
--floating preview in right
@@ -1684,25 +1776,26 @@ describe('builtin popupmenu', function()
}
end
- -- info window position should be adjusted when new leader add
- feed('<C-P>o')
+ -- delete one character make the pum width smaller than before
+ -- info window position should be adjusted when popupmenu width changed
+ feed('<BS>')
if multigrid then
- screen:expect {
+ screen:expect({
grid = [[
- ## grid 1
- [2:----------------------------------------]|*10
- [3:----------------------------------------]|
- ## grid 2
- o^ |
- {1:~ }|*9
- ## grid 3
- {2:-- }{8:Back at original} |
- ## grid 4
- {n:1info}|
- {n: }|
- ## grid 5
- {n:one }|
- ]],
+ ## grid 1
+ [2:----------------------------------------]|*10
+ [3:----------------------------------------]|
+ ## grid 2
+ on^ |
+ {1:~ }|*9
+ ## grid 3
+ {2:-- }{5:match 1 of 3} |
+ ## grid 4
+ {n:1info}|
+ {n: }|
+ ## grid 5
+ {s:one }|
+ ]],
float_pos = {
[5] = { -1, 'NW', 2, 1, 0, false, 100 },
[4] = { 1001, 'NW', 1, 1, 15, false, 50 },
@@ -1713,7 +1806,7 @@ describe('builtin popupmenu', function()
topline = 0,
botline = 2,
curline = 0,
- curcol = 1,
+ curcol = 2,
linecount = 1,
sum_scroll_delta = 0,
},
@@ -1727,22 +1820,88 @@ describe('builtin popupmenu', function()
sum_scroll_delta = 0,
},
},
- }
+ win_viewport_margins = {
+ [2] = {
+ bottom = 0,
+ left = 0,
+ right = 0,
+ top = 0,
+ win = 1000,
+ },
+ [4] = {
+ bottom = 0,
+ left = 0,
+ right = 0,
+ top = 0,
+ win = 1001,
+ },
+ },
+ })
else
- screen:expect {
+ screen:expect({
grid = [[
- o^ |
- {n:one 1info}{1: }|
- {1:~ }{n: }{1: }|
- {1:~ }|*7
- {2:-- }{8:Back at original} |
- ]],
- }
+ on^ |
+ {s:one }{n:1info}{1: }|
+ {1:~ }{n: }{1: }|
+ {1:~ }|*7
+ {2:-- }{5:match 1 of 3} |
+ ]],
+ })
+ end
+
+ -- when back to original the preview float should be closed.
+ feed('<C-P>')
+ if multigrid then
+ screen:expect({
+ grid = [[
+ ## grid 1
+ [2:----------------------------------------]|*10
+ [3:----------------------------------------]|
+ ## grid 2
+ on^ |
+ {1:~ }|*9
+ ## grid 3
+ {2:-- }{8:Back at original} |
+ ## grid 5
+ {n:one }|
+ ]],
+ float_pos = {
+ [5] = { -1, 'NW', 2, 1, 0, false, 100 },
+ },
+ win_viewport = {
+ [2] = {
+ win = 1000,
+ topline = 0,
+ botline = 2,
+ curline = 0,
+ curcol = 2,
+ linecount = 1,
+ sum_scroll_delta = 0,
+ },
+ },
+ win_viewport_margins = {
+ [2] = {
+ bottom = 0,
+ left = 0,
+ right = 0,
+ top = 0,
+ win = 1000,
+ },
+ },
+ })
+ else
+ screen:expect({
+ grid = [[
+ on^ |
+ {n:one }{1: }|
+ {1:~ }|*8
+ {2:-- }{8:Back at original} |
+ ]],
+ })
end
-- test nvim__complete_set_info
- feed('<ESC>cc<C-X><C-O><C-N><C-N>')
- vim.uv.sleep(10)
+ feed('<ESC>S<C-X><C-O><C-N><C-N>')
if multigrid then
screen:expect {
grid = [[
@@ -1758,13 +1917,13 @@ describe('builtin popupmenu', function()
{n:one }|
{n:two }|
{s:looooooooooooooong }|
- ## grid 6
+ ## grid 7
{n:3info}|
{n: }|
]],
float_pos = {
[5] = { -1, 'NW', 2, 1, 0, false, 100 },
- [6] = { 1002, 'NW', 1, 1, 19, false, 50 },
+ [7] = { 1003, 'NW', 1, 1, 19, false, 50 },
},
win_viewport = {
[2] = {
@@ -1776,8 +1935,8 @@ describe('builtin popupmenu', function()
linecount = 1,
sum_scroll_delta = 0,
},
- [6] = {
- win = 1002,
+ [7] = {
+ win = 1003,
topline = 0,
botline = 2,
curline = 0,
@@ -1819,12 +1978,12 @@ describe('builtin popupmenu', function()
{s: one }|
{n: two }|
{n: looooooooooooooong }|
- ## grid 7
+ ## grid 8
{n:1info}|
{n: }|
]],
float_pos = {
- [7] = { 1003, 'NW', 1, 1, 14, false, 50 },
+ [8] = { 1004, 'NW', 1, 1, 14, false, 50 },
[5] = { -1, 'NW', 2, 1, 19, false, 100 },
},
win_viewport = {
@@ -1837,8 +1996,8 @@ describe('builtin popupmenu', function()
linecount = 1,
sum_scroll_delta = 0,
},
- [7] = {
- win = 1003,
+ [8] = {
+ win = 1004,
topline = 0,
botline = 2,
curline = 0,
@@ -1860,6 +2019,90 @@ describe('builtin popupmenu', function()
]],
}
end
+ feed('<C-E><Esc>')
+
+ -- works when scroll with treesitter highlight
+ command('call TestTs()')
+ feed('S<C-x><C-o>')
+ if multigrid then
+ screen:expect({
+ grid = [[
+ ## grid 1
+ [2:----------------------------------------]|*10
+ [3:----------------------------------------]|
+ ## grid 2
+ one^ |
+ {1:~ }|*9
+ ## grid 3
+ {2:-- }{5:match 1 of 3} |
+ ## grid 5
+ {s:one }|
+ {n:two }|
+ {n:looooooooooooooong }|
+ ## grid 9
+ {n:```lua }|
+ {n:function test()}|
+ {n: print('foo') }|
+ {n:end }|
+ {n:``` }|
+ {n: }|
+ ]],
+ float_pos = {
+ [5] = { -1, 'NW', 2, 1, 0, false, 100 },
+ [9] = { 1005, 'NW', 1, 1, 19, false, 50 },
+ },
+ win_viewport = {
+ [2] = {
+ win = 1000,
+ topline = 0,
+ botline = 2,
+ curline = 0,
+ curcol = 3,
+ linecount = 1,
+ sum_scroll_delta = 0,
+ },
+ [9] = {
+ win = 1005,
+ topline = 0,
+ botline = 6,
+ curline = 0,
+ curcol = 0,
+ linecount = 5,
+ sum_scroll_delta = 0,
+ },
+ },
+ win_viewport_margins = {
+ [2] = {
+ bottom = 0,
+ left = 0,
+ right = 0,
+ top = 0,
+ win = 1000,
+ },
+ [9] = {
+ bottom = 0,
+ left = 0,
+ right = 0,
+ top = 0,
+ win = 1005,
+ },
+ },
+ })
+ else
+ screen:expect({
+ grid = [[
+ one^ |
+ {s:one }{n:```lua }{1: }|
+ {n:two function test()}{1: }|
+ {n:looooooooooooooong print('foo') }{1: }|
+ {1:~ }{n:end }{1: }|
+ {1:~ }{n:``` }{1: }|
+ {1:~ }{n: }{1: }|
+ {1:~ }|*3
+ {2:-- }{5:match 1 of 3} |
+ ]],
+ })
+ end
end)
end)
@@ -3846,7 +4089,7 @@ describe('builtin popupmenu', function()
set mouse=a mousemodel=popup
" Delete the default MenuPopup event handler.
- autocmd! nvim_popupmenu
+ autocmd! nvim.popupmenu
aunmenu PopUp
menu PopUp.foo :let g:menustr = 'foo'<CR>
menu PopUp.bar :let g:menustr = 'bar'<CR>
@@ -4703,7 +4946,7 @@ describe('builtin popupmenu', function()
it(':popup command', function()
exec([[
" Delete the default MenuPopup event handler.
- autocmd! nvim_popupmenu
+ autocmd! nvim.popupmenu
func ChangeMenu()
aunmenu PopUp.&Paste
@@ -4863,7 +5106,7 @@ describe('builtin popupmenu', function()
exec([[
set mousemodel=popup_setpos
" Delete the default MenuPopup event handler.
- autocmd! nvim_popupmenu
+ autocmd! nvim.popupmenu
aunmenu *
source $VIMRUNTIME/menu.vim
call setline(1, join(range(20)))
@@ -5172,6 +5415,45 @@ describe('builtin popupmenu', function()
feed('<C-E><Esc>')
end)
+ -- oldtest: Test_pum_highlights_match_with_abbr()
+ it('can highlight matched text with abbr', function()
+ exec([[
+ func Omni_test(findstart, base)
+ if a:findstart
+ return col(".")
+ endif
+ return {
+ \ 'words': [
+ \ { 'word': 'foobar', 'abbr': "foobar\t\t!" },
+ \ { 'word': 'foobaz', 'abbr': "foobaz\t\t!" },
+ \]}
+ endfunc
+
+ set omnifunc=Omni_test
+ set completeopt=menuone,noinsert
+ hi PmenuMatchSel guifg=Blue guibg=Grey
+ hi PmenuMatch guifg=Blue guibg=Plum1
+ ]])
+ feed('i<C-X><C-O>')
+ screen:expect([[
+ ^ |
+ {s:foobar ! }{1: }|
+ {n:foobaz ! }{1: }|
+ {1:~ }|*16
+ {2:-- }{5:match 1 of 2} |
+ ]])
+ feed('foo')
+ screen:expect([[
+ foo^ |
+ {ms:foo}{s:bar ! }{1: }|
+ {mn:foo}{n:baz ! }{1: }|
+ {1:~ }|*16
+ {2:-- }{5:match 1 of 2} |
+ ]])
+
+ feed('<C-E><Esc>')
+ end)
+
-- oldtest: Test_pum_user_abbr_hlgroup()
it('custom abbr_hlgroup override', function()
exec([[
@@ -5419,6 +5701,240 @@ describe('builtin popupmenu', function()
]])
feed('<C-E><ESC>')
end)
+
+ -- oldtest: Test_pum_matchins_highlight()
+ it('with ComplMatchIns highlight', function()
+ exec([[
+ let g:change = 0
+ func Omni_test(findstart, base)
+ if a:findstart
+ return col(".")
+ endif
+ if g:change == 0
+ return [#{word: "foo"}, #{word: "bar"}, #{word: "你好"}]
+ endif
+ return [#{word: "foo", info: "info"}, #{word: "bar"}, #{word: "你好"}]
+ endfunc
+ set omnifunc=Omni_test
+ hi ComplMatchIns guifg=red
+ ]])
+
+ feed('Sαβγ <C-X><C-O>')
+ screen:expect([[
+ αβγ {8:foo}^ |
+ {1:~ }{s: foo }{1: }|
+ {1:~ }{n: bar }{1: }|
+ {1:~ }{n: 你好 }{1: }|
+ {1:~ }|*15
+ {2:-- }{5:match 1 of 3} |
+ ]])
+ feed('<C-E><Esc>')
+
+ feed('Sαβγ <C-X><C-O><C-N>')
+ screen:expect([[
+ αβγ {8:bar}^ |
+ {1:~ }{n: foo }{1: }|
+ {1:~ }{s: bar }{1: }|
+ {1:~ }{n: 你好 }{1: }|
+ {1:~ }|*15
+ {2:-- }{5:match 2 of 3} |
+ ]])
+ feed('<C-E><Esc>')
+
+ feed('Sαβγ <C-X><C-O><C-N><C-N>')
+ screen:expect([[
+ αβγ {8:你好}^ |
+ {1:~ }{n: foo }{1: }|
+ {1:~ }{n: bar }{1: }|
+ {1:~ }{s: 你好 }{1: }|
+ {1:~ }|*15
+ {2:-- }{5:match 3 of 3} |
+ ]])
+ feed('<C-E><Esc>')
+
+ -- restore after accept
+ feed('Sαβγ <C-X><C-O><C-Y>')
+ screen:expect([[
+ αβγ foo^ |
+ {1:~ }|*18
+ {2:-- INSERT --} |
+ ]])
+ feed('<Esc>')
+
+ -- restore after cancel completion
+ feed('Sαβγ <C-X><C-O><Space>')
+ screen:expect([[
+ αβγ foo ^ |
+ {1:~ }|*18
+ {2:-- INSERT --} |
+ ]])
+ feed('<Esc>')
+
+ -- text after the inserted text shouldn't be highlighted
+ feed('0ea <C-X><C-O>')
+ screen:expect([[
+ αβγ {8:foo}^ foo |
+ {1:~ }{s: foo }{1: }|
+ {1:~ }{n: bar }{1: }|
+ {1:~ }{n: 你好 }{1: }|
+ {1:~ }|*15
+ {2:-- }{5:match 1 of 3} |
+ ]])
+ feed('<C-P>')
+ screen:expect([[
+ αβγ ^ foo |
+ {1:~ }{n: foo }{1: }|
+ {1:~ }{n: bar }{1: }|
+ {1:~ }{n: 你好 }{1: }|
+ {1:~ }|*15
+ {2:-- }{8:Back at original} |
+ ]])
+ feed('<C-P>')
+ screen:expect([[
+ αβγ {8:你好}^ foo |
+ {1:~ }{n: foo }{1: }|
+ {1:~ }{n: bar }{1: }|
+ {1:~ }{s: 你好 }{1: }|
+ {1:~ }|*15
+ {2:-- }{5:match 3 of 3} |
+ ]])
+ feed('<C-Y>')
+ screen:expect([[
+ αβγ 你好^ foo |
+ {1:~ }|*18
+ {2:-- INSERT --} |
+ ]])
+ feed('<Esc>')
+
+ feed(':let g:change=1<CR>S<C-X><C-O>')
+ screen:expect([[
+ info |
+ {1:~ }|*2
+ {3:[Scratch] [Preview] }|
+ {8:foo}^ |
+ {s:foo }{1: }|
+ {n:bar }{1: }|
+ {n:你好 }{1: }|
+ {1:~ }|*10
+ {4:[No Name] [+] }|
+ {2:-- }{5:match 1 of 3} |
+ ]])
+ feed('<Esc>')
+ end)
+
+ -- oldtest: Test_pum_matchins_highlight_combine()
+ it('with ComplMatchIns, Normal and CursorLine highlights', function()
+ exec([[
+ func Omni_test(findstart, base)
+ if a:findstart
+ return col(".")
+ endif
+ return [#{word: "foo"}, #{word: "bar"}, #{word: "你好"}]
+ endfunc
+ set omnifunc=Omni_test
+ hi Normal guibg=blue
+ hi CursorLine guibg=green guifg=white
+ set cursorline
+ call setline(1, 'aaa bbb')
+ ]])
+
+ -- when ComplMatchIns is not set, CursorLine applies normally
+ feed('0ea <C-X><C-O>')
+ screen:expect([[
+ {10:aaa foo^ bbb }|
+ {1:~ }{s: foo }{1: }|
+ {1:~ }{n: bar }{1: }|
+ {1:~ }{n: 你好 }{1: }|
+ {1:~ }|*15
+ {2:-- }{5:match 1 of 3} |
+ ]])
+ feed('<C-E>')
+ screen:expect([[
+ {10:aaa ^ bbb }|
+ {1:~ }|*18
+ {2:-- INSERT --} |
+ ]])
+ feed('<BS><Esc>')
+
+ -- when ComplMatchIns is set, it is applied over CursorLine
+ command('hi ComplMatchIns guifg=Yellow')
+ feed('0ea <C-X><C-O>')
+ screen:expect([[
+ {10:aaa }{9:foo}{10:^ bbb }|
+ {1:~ }{s: foo }{1: }|
+ {1:~ }{n: bar }{1: }|
+ {1:~ }{n: 你好 }{1: }|
+ {1:~ }|*15
+ {2:-- }{5:match 1 of 3} |
+ ]])
+ feed('<C-P>')
+ screen:expect([[
+ {10:aaa ^ bbb }|
+ {1:~ }{n: foo }{1: }|
+ {1:~ }{n: bar }{1: }|
+ {1:~ }{n: 你好 }{1: }|
+ {1:~ }|*15
+ {2:-- }{8:Back at original} |
+ ]])
+ feed('<C-P>')
+ screen:expect([[
+ {10:aaa }{9:你好}{10:^ bbb }|
+ {1:~ }{n: foo }{1: }|
+ {1:~ }{n: bar }{1: }|
+ {1:~ }{s: 你好 }{1: }|
+ {1:~ }|*15
+ {2:-- }{5:match 3 of 3} |
+ ]])
+ feed('<C-E>')
+ screen:expect([[
+ {10:aaa ^ bbb }|
+ {1:~ }|*18
+ {2:-- INSERT --} |
+ ]])
+ feed('<Esc>')
+
+ -- Does not highlight the compl leader
+ command('set cot+=menuone,noselect')
+ feed('S<C-X><C-O>')
+ local pum_start = [[
+ {10:^ }|
+ {n:foo }{1: }|
+ {n:bar }{1: }|
+ {n:你好 }{1: }|
+ {1:~ }|*15
+ {2:-- }{8:Back at original} |
+ ]]
+ screen:expect(pum_start)
+ feed('f<C-N>')
+ screen:expect([[
+ {10:f}{9:oo}{10:^ }|
+ {s:foo }{1: }|
+ {1:~ }|*17
+ {2:-- }{5:match 1 of 3} |
+ ]])
+ feed('<C-E><ESC>')
+
+ command('set cot+=fuzzy')
+ feed('S<C-X><C-O>')
+ screen:expect(pum_start)
+ feed('f<C-N>')
+ screen:expect([[
+ {10:foo^ }|
+ {s:foo }{1: }|
+ {1:~ }|*17
+ {2:-- }{5:match 1 of 3} |
+ ]])
+ feed('<C-E><Esc>')
+
+ command('set cot-=fuzzy')
+ feed('Sf<C-N>')
+ screen:expect([[
+ {10:f^ }|
+ {1:~ }|*18
+ {2:-- }{6:Pattern not found} |
+ ]])
+ feed('<C-E><Esc>')
+ end)
end
end
diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua
index 8e15e6c35f..6a8e7df6a0 100644
--- a/test/functional/ui/screen.lua
+++ b/test/functional/ui/screen.lua
@@ -37,10 +37,10 @@
-- Tests will often share a group of extra attribute sets to expect(). Those can be
-- defined at the beginning of a test:
--
--- screen:add_extra_attr_ids {
+-- screen:add_extra_attr_ids({
-- [100] = { background = Screen.colors.Plum1, underline = true },
-- [101] = { background = Screen.colors.Red1, bold = true, underline = true },
--- }
+-- })
--
-- To help write screen tests, see Screen:snapshot_util().
-- To debug screen tests, see Screen:redraw_debug().
@@ -79,6 +79,7 @@ end
--- @field win_position table<integer,table<string,integer>>
--- @field float_pos table<integer,table>
--- @field cmdline table<integer,table>
+--- @field cmdline_hide_level integer?
--- @field cmdline_block table[]
--- @field hl_groups table<string,integer>
--- @field messages table<integer,table>
@@ -454,7 +455,7 @@ end
--- screen:expect(grid, [attr_ids])
--- screen:expect(condition)
--- or keyword args (supports more options):
---- screen:expect{grid=[[...]], cmdline={...}, condition=function() ... end}
+--- screen:expect({ grid=[[...]], cmdline={...}, condition=function() ... end })
---
--- @param expected string|function|test.function.ui.screen.Expect
--- @param attr_ids? table<integer,table<string,any>>
@@ -654,6 +655,12 @@ screen:redraw_debug() to show all intermediate screen states.]]
end
end
+ -- Only test the abort state of a cmdline level once.
+ if self.cmdline_hide_level ~= nil then
+ self.cmdline[self.cmdline_hide_level] = nil
+ self.cmdline_hide_level = nil
+ end
+
if expected.hl_groups ~= nil then
for name, id in pairs(expected.hl_groups) do
local expected_hl = attr_state.ids[id]
@@ -967,11 +974,11 @@ function Screen:_handle_mode_info_set(cursor_style_enabled, mode_info)
self._cursor_style_enabled = cursor_style_enabled
for _, item in pairs(mode_info) do
-- attr IDs are not stable, but their value should be
- if item.attr_id ~= nil then
+ if item.attr_id ~= nil and self._attr_table[item.attr_id] ~= nil then
item.attr = self._attr_table[item.attr_id][1]
item.attr_id = nil
end
- if item.attr_id_lm ~= nil then
+ if item.attr_id_lm ~= nil and self._attr_table[item.attr_id_lm] ~= nil then
item.attr_lm = self._attr_table[item.attr_id_lm][1]
item.attr_id_lm = nil
end
@@ -1296,7 +1303,7 @@ function Screen:_handle_popupmenu_hide()
self.popupmenu = nil
end
-function Screen:_handle_cmdline_show(content, pos, firstc, prompt, indent, level)
+function Screen:_handle_cmdline_show(content, pos, firstc, prompt, indent, level, hl_id)
if firstc == '' then
firstc = nil
end
@@ -1320,11 +1327,13 @@ function Screen:_handle_cmdline_show(content, pos, firstc, prompt, indent, level
firstc = firstc,
prompt = prompt,
indent = indent,
+ hl_id = prompt and hl_id,
}
end
-function Screen:_handle_cmdline_hide(level)
- self.cmdline[level] = nil
+function Screen:_handle_cmdline_hide(level, abort)
+ self.cmdline[level] = { abort = abort }
+ self.cmdline_hide_level = level
end
function Screen:_handle_cmdline_special_char(char, shift, level)
@@ -1360,12 +1369,12 @@ function Screen:_handle_wildmenu_hide()
self.wildmenu_items, self.wildmenu_pos = nil, nil
end
-function Screen:_handle_msg_show(kind, chunks, replace_last)
+function Screen:_handle_msg_show(kind, chunks, replace_last, history)
local pos = #self.messages
if not replace_last or pos == 0 then
pos = pos + 1
end
- self.messages[pos] = { kind = kind, content = chunks }
+ self.messages[pos] = { kind = kind, content = chunks, history = history }
end
function Screen:_handle_msg_clear()
@@ -1468,7 +1477,9 @@ function Screen:_extstate_repr(attr_state)
local cmdline = {}
for i, entry in pairs(self.cmdline) do
entry = shallowcopy(entry)
- entry.content = self:_chunks_repr(entry.content, attr_state)
+ if entry.content ~= nil then
+ entry.content = self:_chunks_repr(entry.content, attr_state)
+ end
cmdline[i] = entry
end
@@ -1479,7 +1490,11 @@ function Screen:_extstate_repr(attr_state)
local messages = {}
for i, entry in ipairs(self.messages) do
- messages[i] = { kind = entry.kind, content = self:_chunks_repr(entry.content, attr_state) }
+ messages[i] = {
+ kind = entry.kind,
+ content = self:_chunks_repr(entry.content, attr_state),
+ history = entry.history,
+ }
end
local msg_history = {}
@@ -1713,21 +1728,24 @@ function Screen:_print_snapshot()
end
end
local fn_name = modify_attrs and 'add_extra_attr_ids' or 'set_default_attr_ids'
- attrstr = ('screen:' .. fn_name .. ' {\n' .. table.concat(attrstrs, '\n') .. '\n}\n\n')
+ attrstr = ('screen:' .. fn_name .. '({\n' .. table.concat(attrstrs, '\n') .. '\n})\n\n')
end
- local result = ('%sscreen:expect({\n grid = [[\n %s\n ]]'):format(
- attrstr,
- kwargs.grid:gsub('\n', '\n ')
- )
+ local extstr = ''
for _, k in ipairs(ext_keys) do
if ext_state[k] ~= nil and not (k == 'win_viewport' and not self.options.ext_multigrid) then
- result = result .. ', ' .. k .. '=' .. fmt_ext_state(k, ext_state[k])
+ extstr = extstr .. '\n ' .. k .. ' = ' .. fmt_ext_state(k, ext_state[k]) .. ','
end
end
- result = result .. '\n})'
- return result
+ return ('%sscreen:expect(%s%s%s%s%s'):format(
+ attrstr,
+ #extstr > 0 and '{\n grid = [[\n ' or '[[\n',
+ #extstr > 0 and kwargs.grid:gsub('\n', '\n ') or kwargs.grid,
+ #extstr > 0 and '\n ]],' or '\n]]',
+ extstr,
+ #extstr > 0 and '\n})' or ')'
+ )
end
function Screen:print_snapshot()
diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua
index f39e9ecc33..295c40b9b6 100644
--- a/test/functional/ui/screen_basic_spec.lua
+++ b/test/functional/ui/screen_basic_spec.lua
@@ -2,7 +2,7 @@ local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
-local spawn, set_session, clear = n.spawn, n.set_session, n.clear
+local set_session, clear = n.set_session, n.clear
local feed, command = n.feed, n.command
local exec = n.exec
local insert = n.insert
@@ -26,7 +26,7 @@ describe('screen', function()
}
before_each(function()
- local screen_nvim = spawn(nvim_argv)
+ local screen_nvim = n.new_session(false, { args = nvim_argv, merge = false })
set_session(screen_nvim)
screen = Screen.new()
end)
@@ -645,6 +645,59 @@ local function screen_tests(linegrid)
|
]])
end)
+
+ it('clamps &cmdheight for current tabpage', function()
+ command('set cmdheight=10 laststatus=2')
+ screen:expect([[
+ ^ |
+ {0:~ }|*2
+ {1:[No Name] }|
+ |*10
+ ]])
+ screen:try_resize(53, 8)
+ screen:expect([[
+ ^ |
+ {1:[No Name] }|
+ |*6
+ ]])
+ eq(6, api.nvim_get_option_value('cmdheight', {}))
+ end)
+
+ it('clamps &cmdheight for another tabpage #31380', function()
+ command('tabnew')
+ command('set cmdheight=9 laststatus=2')
+ screen:expect([[
+ {4: [No Name] }{2: [No Name] }{3: }{4:X}|
+ ^ |
+ {0:~ }|*2
+ {1:[No Name] }|
+ |*9
+ ]])
+ command('tabprev')
+ screen:expect([[
+ {2: [No Name] }{4: [No Name] }{3: }{4:X}|
+ ^ |
+ {0:~ }|*10
+ {1:[No Name] }|
+ |
+ ]])
+ screen:try_resize(53, 8)
+ screen:expect([[
+ {2: [No Name] }{4: [No Name] }{3: }{4:X}|
+ ^ |
+ {0:~ }|*4
+ {1:[No Name] }|
+ |
+ ]])
+ command('tabnext')
+ screen:expect([[
+ {4: [No Name] }{2: [No Name] }{3: }{4:X}|
+ ^ |
+ {1:[No Name] }|
+ |*5
+ ]])
+ eq(5, api.nvim_get_option_value('cmdheight', {}))
+ end)
end)
describe('press enter', function()
@@ -713,7 +766,7 @@ describe('Screen default colors', function()
'colorscheme vim',
'--embed',
}
- local screen_nvim = spawn(nvim_argv)
+ local screen_nvim = n.new_session(false, { args = nvim_argv, merge = false })
set_session(screen_nvim)
screen = Screen.new(53, 14, { rgb = true, ext_termcolors = termcolors or nil })
end
diff --git a/test/functional/ui/sign_spec.lua b/test/functional/ui/sign_spec.lua
index 7874c04c39..ff03d86979 100644
--- a/test/functional/ui/sign_spec.lua
+++ b/test/functional/ui/sign_spec.lua
@@ -14,6 +14,10 @@ describe('Signs', function()
screen = Screen.new()
screen:add_extra_attr_ids {
[100] = { bold = true, foreground = Screen.colors.Magenta1 },
+ [101] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.Yellow1 },
+ [102] = { foreground = Screen.colors.Brown, background = Screen.colors.Yellow },
+ [103] = { background = Screen.colors.Yellow, reverse = true },
+ [104] = { reverse = true, foreground = Screen.colors.Grey100, background = Screen.colors.Red },
}
end)
@@ -27,8 +31,8 @@ describe('Signs', function()
sign place 2 line=2 name=piet2 buffer=1
]])
screen:expect([[
- {10:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}a |
- {10:𠜎̀́̂̃̄̅}b |
+ {101:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}a |
+ {101:𠜎̀́̂̃̄̅}b |
{7: }^ |
{1:~ }|*10
|
@@ -45,9 +49,9 @@ describe('Signs', function()
sign place 3 line=1 name=pietx buffer=1
]])
screen:expect([[
- {10:>!}a |
+ {101:>!}a |
{7: }b |
- {10:>>}c |
+ {101:>>}c |
{7: }^ |
{1:~ }|*9
|
@@ -80,13 +84,13 @@ describe('Signs', function()
]])
screen:expect([[
{7: }{21:^a }|
- {10:>>}b |
+ {101:>>}b |
{7: }c |
{7: } |
{1:~ }|*2
{3:[No Name] [+] }|
{7: }{21:a }|
- {10:>>}b |
+ {101:>>}b |
{7: }c |
{7: } |
{1:~ }|
@@ -110,10 +114,10 @@ describe('Signs', function()
sign place 6 line=4 name=pietxx buffer=1
]])
screen:expect([[
- {10:>>}{8: 1 }a |
+ {101:>>}{8: 1 }a |
{7: }{8: 2 }{9:b }|
{7: }{13: 3 }c |
- {10:>>}{13: 4 }{9:^ }|
+ {101:>>}{13: 4 }{9:^ }|
{1:~ }|*9
|
]])
@@ -132,33 +136,33 @@ describe('Signs', function()
set cursorline
]])
screen:expect([[
- {10:>>}a |
- {10:>>}b |
+ {101:>>}a |
+ {101:>>}b |
{9:>>}{21:^c }|
{1:~ }|*10
|
]])
feed('k')
screen:expect([[
- {10:>>}a |
+ {101:>>}a |
{9:>>}{21:^b }|
- {10:>>}c |
+ {101:>>}c |
{1:~ }|*10
|
]])
exec('set nocursorline')
screen:expect([[
- {10:>>}a |
- {10:>>}^b |
- {10:>>}c |
+ {101:>>}a |
+ {101:>>}^b |
+ {101:>>}c |
{1:~ }|*10
|
]])
exec('set cursorline cursorlineopt=line')
screen:expect([[
- {10:>>}a |
- {10:>>}{21:^b }|
- {10:>>}c |
+ {101:>>}a |
+ {101:>>}{21:^b }|
+ {101:>>}c |
{1:~ }|*10
|
]])
@@ -166,13 +170,14 @@ describe('Signs', function()
exec('hi! link SignColumn IncSearch')
feed('Go<esc>2G')
screen:expect([[
- {10:>>}a |
- {9:>>}^b |
- {10:>>}c |
+ {103:>>}a |
+ {104:>>}^b |
+ {103:>>}c |
{2: } |
{1:~ }|*9
|
]])
+
-- Check that 'statuscolumn' cursorline/signcolumn highlights are the same (#21726)
exec('set statuscolumn=%s')
screen:expect_unchanged()
@@ -196,7 +201,7 @@ describe('Signs', function()
screen:expect([[
{7: }{8: 1 }a |
{7: }{8: 2 }b |
- WW{10:>>}{8: 3 }c |
+ {7:WW}{101:>>}{8: 3 }c |
{7: }{8: 4 }^ |
{1:~ }|*9
|
@@ -209,9 +214,9 @@ describe('Signs', function()
sign place 3 line=2 name=pietError buffer=1
]])
screen:expect([[
- {9:XX}{10:>>}{8: 1 }a |
- {10:>>}{9:XX}{8: 2 }b |
- WW{10:>>}{8: 3 }c |
+ {9:XX}{101:>>}{8: 1 }a |
+ {101:>>}{9:XX}{8: 2 }b |
+ {7:WW}{101:>>}{8: 3 }c |
{7: }{8: 4 }^ |
{1:~ }|*9
|
@@ -220,8 +225,8 @@ describe('Signs', function()
exec('set signcolumn=yes:1')
screen:expect([[
{9:XX}{8: 1 }a |
- {10:>>}{8: 2 }b |
- WW{8: 3 }c |
+ {101:>>}{8: 2 }b |
+ {7:WW}{8: 3 }c |
{7: }{8: 4 }^ |
{1:~ }|*9
|
@@ -229,9 +234,9 @@ describe('Signs', function()
-- "auto:3" accommodates all the signs we defined so far.
exec('set signcolumn=auto:3')
local s3 = [[
- {9:XX}{10:>>}{7: }{8: 1 }a |
- {10:>>}{9:XX}{7: }{8: 2 }b |
- WW{10:>>}{9:XX}{8: 3 }c |
+ {9:XX}{101:>>}{7: }{8: 1 }a |
+ {101:>>}{9:XX}{7: }{8: 2 }b |
+ {7:WW}{101:>>}{9:XX}{8: 3 }c |
{7: }{8: 4 }^ |
{1:~ }|*9
|
@@ -240,9 +245,9 @@ describe('Signs', function()
-- Check "yes:9".
exec('set signcolumn=yes:9')
screen:expect([[
- {9:XX}{10:>>}{7: }{8: 1 }a |
- {10:>>}{9:XX}{7: }{8: 2 }b |
- WW{10:>>}{9:XX}{7: }{8: 3 }c |
+ {9:XX}{101:>>}{7: }{8: 1 }a |
+ {101:>>}{9:XX}{7: }{8: 2 }b |
+ {7:WW}{101:>>}{9:XX}{7: }{8: 3 }c |
{7: }{8: 4 }^ |
{1:~ }|*9
|
@@ -255,8 +260,8 @@ describe('Signs', function()
exec('3move1')
exec('2d')
screen:expect([[
- {9:XX}{10:>>}{8: 1 }a |
- {10:>>}{9:XX}{8: 2 }^b |
+ {9:XX}{101:>>}{8: 1 }a |
+ {101:>>}{9:XX}{8: 2 }^b |
{7: }{8: 3 } |
{1:~ }|*10
|
@@ -264,8 +269,8 @@ describe('Signs', function()
-- character deletion does not delete signs.
feed('x')
screen:expect([[
- {9:XX}{10:>>}{8: 1 }a |
- {10:>>}{9:XX}{8: 2 }^ |
+ {9:XX}{101:>>}{8: 1 }a |
+ {101:>>}{9:XX}{8: 2 }^ |
{7: }{8: 3 } |
{1:~ }|*10
|
@@ -301,7 +306,7 @@ describe('Signs', function()
exec('sign define pietSearch text=>> texthl=Search')
exec('sign place 1 line=1 name=pietSearch buffer=1')
screen:expect([[
- {10:>>}{7: }{8: 1 }a |
+ {101:>>}{7: }{8: 1 }a |
{7: }{8: 2 }b |
{7: }{8: 3 }c |
{7: }{8: 4 }^ |
@@ -316,7 +321,7 @@ describe('Signs', function()
sign place 4 line=1 name=pietSearch buffer=1
]])
screen:expect([[
- {10:>>>>>>>>}{8: 1 }a |
+ {101:>>>>>>>>}{8: 1 }a |
{7: }{8: 2 }b |
{7: }{8: 3 }c |
{7: }{8: 4 }^ |
@@ -328,7 +333,7 @@ describe('Signs', function()
screen:expect_unchanged()
exec('sign unplace 4')
screen:expect([[
- {10:>>>>>>}{8: 1 }a |
+ {101:>>>>>>}{8: 1 }a |
{7: }{8: 2 }b |
{7: }{8: 3 }c |
{7: }{8: 4 }^ |
@@ -345,7 +350,7 @@ describe('Signs', function()
sign place 8 line=1 name=pietSearch buffer=1
]])
screen:expect([[
- {10:>>>>>>>>>>}{8: 1 }a |
+ {101:>>>>>>>>>>}{8: 1 }a |
{7: }{8: 2 }b |
{7: }{8: 3 }c |
{7: }{8: 4 }^ |
@@ -375,7 +380,7 @@ describe('Signs', function()
-- single column with 1 sign with text and one sign without
exec('sign place 1 line=1 name=pietSearch buffer=1')
screen:expect([[
- {10:>>}{8: 1 }a |
+ {101:>>}{8: 1 }a |
{7: }{8: 2 }b |
{7: }{8: 3 }c |
{7: }{8: 4 }^ |
@@ -396,7 +401,7 @@ describe('Signs', function()
-- line number should be drawn if sign has no text
-- no signcolumn, line number for "a" is Search, for "b" is Error, for "c" is LineNr
screen:expect([[
- {10: >> }a |
+ {101: >> }a |
{9: 2 }b |
{8: 3 }c |
{8: 4 }^ |
@@ -406,7 +411,7 @@ describe('Signs', function()
-- number column on wrapped part of a line should be empty
feed('gg100aa<Esc>')
screen:expect([[
- {10: >> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ {101: >> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{9: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{9: }aa^a |
{9: 2 }b |
@@ -423,7 +428,7 @@ describe('Signs', function()
-- number column on virtual lines should be empty
screen:expect([[
{8: }VIRT LINES |
- {10: >> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ {101: >> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{9: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{9: }aa^a |
{9: 2 }b |
@@ -439,7 +444,7 @@ describe('Signs', function()
exec('sign place 100000 line=1 name=piet buffer=1')
feed(':sign place<cr>')
screen:expect([[
- {10:>>} |
+ {101:>>} |
{1:~ }|*6
{3: }|
:sign place |
@@ -452,7 +457,7 @@ describe('Signs', function()
feed('<cr>')
screen:expect([[
- {10:>>}^ |
+ {101:>>}^ |
{1:~ }|*12
|
]])
@@ -470,7 +475,7 @@ describe('Signs', function()
{7: }a |
{7: }^c |
{7: }d |
- >>e |
+ {7:>>}e |
{1:~ }|*9
|
]])
@@ -498,7 +503,7 @@ describe('Signs', function()
{7: }b |
{7: }c |
{7: }d |
- >>e |
+ {7:>>}e |
{1:~ }|*7
|
]])
@@ -550,7 +555,7 @@ describe('Signs', function()
exec('silent undo')
screen:expect([[
{7: }1 |
- S1^2 |
+ {7:S1}^2 |
{7: }3 |
{7: }4 |
{1:~ }|*9
@@ -575,23 +580,19 @@ describe('Signs', function()
sign place 2 line=9 name=S2
]])
-- Now placed at end of buffer
- local s1 = {
- grid = [[
- S2^ |
- {1:~ }|*12
- |
- ]],
- }
+ local s1 = [[
+ {7:S2}^ |
+ {1:~ }|*12
+ |
+ ]]
screen:expect(s1)
-- Signcolumn tracking used to not count signs placed beyond end of buffer here
exec('set signcolumn=auto:9')
- screen:expect({
- grid = [[
- S2S1^ |
- {1:~ }|*12
- |
- ]],
- })
+ screen:expect([[
+ {7:S2S1}^ |
+ {1:~ }|*12
+ |
+ ]])
-- Unplacing the sign does not crash by decrementing tracked signs below zero
exec('sign unplace 1')
screen:expect(s1)
@@ -607,4 +608,77 @@ describe('Signs', function()
eq(6, infos[1].textoff)
eq(6, infos[2].textoff)
end)
+
+ it('auto width updated in all windows after sign placed in on_win #31438', function()
+ exec_lua([[
+ vim.cmd.call('setline(1, range(1, 500))')
+ vim.cmd('wincmd s | wincmd v | wincmd j | wincmd v')
+
+ _G.log, _G.needs_clear = {}, false
+ local ns_id, mark_id = vim.api.nvim_create_namespace('test'), nil
+
+ -- Add decoration which possibly clears all extmarks and adds one on line 499
+ local on_win = function(_, winid, bufnr, toprow, botrow)
+ if _G.needs_clear then
+ vim.api.nvim_buf_clear_namespace(bufnr, ns_id, 0, -1)
+ _G.needs_clear = false
+ end
+
+ if toprow < 499 and 499 <= botrow then
+ mark_id = vim.api.nvim_buf_set_extmark(bufnr, ns_id, 499, 0, { id = mark_id, sign_text = '!', invalidate = true })
+ end
+ end
+ vim.api.nvim_set_decoration_provider(ns_id, { on_win = on_win })
+ ]])
+ screen:expect([[
+ 1 │1 |
+ 2 │2 |
+ 3 │3 |
+ 4 │4 |
+ 5 │5 |
+ 6 │6 |
+ {2:[No Name] [+] [No Name] [+] }|
+ ^1 │1 |
+ 2 │2 |
+ 3 │3 |
+ 4 │4 |
+ 5 │5 |
+ {3:[No Name] [+] }{2:[No Name] [+] }|
+ |
+ ]])
+ feed('G')
+ screen:expect([[
+ {7: }1 │{7: }1 |
+ {7: }2 │{7: }2 |
+ {7: }3 │{7: }3 |
+ {7: }4 │{7: }4 |
+ {7: }5 │{7: }5 |
+ {7: }6 │{7: }6 |
+ {2:[No Name] [+] [No Name] [+] }|
+ {7: }496 │{7: }1 |
+ {7: }497 │{7: }2 |
+ {7: }498 │{7: }3 |
+ {7: }499 │{7: }4 |
+ {7:! }^500 │{7: }5 |
+ {3:[No Name] [+] }{2:[No Name] [+] }|
+ |
+ ]])
+ feed(':lua log, needs_clear = {}, true<CR>')
+ screen:expect([[
+ {7: }1 │{7: }1 |
+ {7: }2 │{7: }2 |
+ {7: }3 │{7: }3 |
+ {7: }4 │{7: }4 |
+ {7: }5 │{7: }5 |
+ {7: }6 │{7: }6 |
+ {2:[No Name] [+] [No Name] [+] }|
+ {7: }496 │{7: }1 |
+ {7: }497 │{7: }2 |
+ {7: }498 │{7: }3 |
+ {7: }499 │{7: }4 |
+ {7:! }^500 │{7: }5 |
+ {3:[No Name] [+] }{2:[No Name] [+] }|
+ :lua log, needs_clear = {}, true |
+ ]])
+ end)
end)
diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua
index 268e7173e6..328e212a22 100644
--- a/test/functional/ui/statuscolumn_spec.lua
+++ b/test/functional/ui/statuscolumn_spec.lua
@@ -13,8 +13,6 @@ local api = n.api
local pcall_err = t.pcall_err
local assert_alive = n.assert_alive
-local mousemodels = { 'extend', 'popup', 'popup_setpos' }
-
describe('statuscolumn', function()
local screen
before_each(function()
@@ -229,15 +227,28 @@ describe('statuscolumn', function()
{1: }{8:8│}aaaaa |
|
]])
+ -- Last segment and fillchar are highlighted properly
+ command("set stc=%#Error#%{v:relnum?'Foo':'FooBar'}")
+ screen:expect([[
+ {9:Foo }aaaaa |*4
+ {9:FooBar}^aaaaa |
+ {9:Foo }aaaaa |*8
+ |
+ ]])
end)
it('works with wrapped lines, signs and folds', function()
- command([[set stc=%C%s%=%{v:virtnum?'':v:lnum}│\ ]])
- command("call setline(1,repeat([repeat('aaaaa',10)],16))")
screen:add_extra_attr_ids {
[100] = { foreground = Screen.colors.Red, background = Screen.colors.LightGray },
+ [101] = { background = Screen.colors.Gray90, bold = true },
+ [102] = { foreground = Screen.colors.Brown, background = Screen.colors.Grey },
+ [103] = { bold = true, background = Screen.colors.Grey, foreground = Screen.colors.Blue1 },
}
- command('hi! CursorLine guifg=Red guibg=NONE')
+ command([[set cursorline stc=%C%s%=%{v:virtnum?'':v:lnum}│\ ]])
+ command("call setline(1,repeat([repeat('aaaaa',10)],16))")
+ command('hi! CursorLine gui=bold')
+ command('sign define num1 numhl=Special')
+ command('sign place 1 line=8 name=num1 buffer=1')
screen:expect([[
{8: 4│ }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{8: │ }a |
@@ -247,8 +258,8 @@ describe('statuscolumn', function()
{8: │ }a |
{8: 7│ }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{8: │ }a |
- {8: 8│ }^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
- {8: │ }a |
+ {29: 8│ }{101:^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
+ {29: │ }{101:a }|
{8: 9│ }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{8: │ }a |
{8:10│ }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{1:@@@}|
@@ -256,7 +267,8 @@ describe('statuscolumn', function()
]])
command([[set stc=%C%s%=%l│\ ]])
screen:expect_unchanged()
- command('set signcolumn=auto:2 foldcolumn=auto')
+ command('hi! CursorLine guifg=Red guibg=NONE gui=NONE')
+ command('set nocursorline signcolumn=auto:2 foldcolumn=auto')
command('sign define piet1 text=>> texthl=LineNr')
command('sign define piet2 text=>! texthl=NonText')
command('sign place 1 line=4 name=piet1 buffer=1')
@@ -264,11 +276,11 @@ describe('statuscolumn', function()
command('sign place 3 line=6 name=piet1 buffer=1')
command('sign place 4 line=6 name=piet2 buffer=1')
screen:expect([[
- {8:>>}{7: }{8: 4│ }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ {102:>>}{7: }{8: 4│ }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: │ }aaaaa |
- {1:>!}{7: }{8: 5│ }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ {103:>!}{7: }{8: 5│ }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: │ }aaaaa |
- {1:>!}{8:>> 6│ }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ {103:>!}{102:>>}{8: 6│ }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: │ }aaaaa |
{7: }{8: 7│ }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: │ }aaaaa |
@@ -283,11 +295,11 @@ describe('statuscolumn', function()
-- Check that alignment works properly with signs after %=
command([[set stc=%C%=%{v:virtnum?'':v:lnum}│%s\ ]])
screen:expect([[
- {7: }{8: 4│>>}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ {7: }{8: 4│}{102:>>}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: │}{7: }{8: }aaaaaa |
- {7: }{8: 5│}{1:>!}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ {7: }{8: 5│}{103:>!}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: │}{7: }{8: }aaaaaa |
- {7: }{8: 6│}{1:>!}{8:>> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ {7: }{8: 6│}{103:>!}{102:>>}{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: │}{7: }{8: }aaaaaa |
{7: }{8: 7│}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: │}{7: }{8: }aaaaaa |
@@ -300,11 +312,11 @@ describe('statuscolumn', function()
]])
command('set cursorline')
screen:expect([[
- {7: }{8: 4│>>}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ {7: }{8: 4│}{102:>>}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: │}{7: }{8: }aaaaaa |
- {7: }{8: 5│}{1:>!}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ {7: }{8: 5│}{103:>!}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: │}{7: }{8: }aaaaaa |
- {7: }{8: 6│}{1:>!}{8:>> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ {7: }{8: 6│}{103:>!}{102:>>}{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: │}{7: }{8: }aaaaaa |
{7: }{8: 7│}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: │}{7: }{8: }aaaaaa |
@@ -318,11 +330,11 @@ describe('statuscolumn', function()
-- v:lnum is the same value on wrapped lines
command([[set stc=%C%=%{v:lnum}│%s\ ]])
screen:expect([[
- {7: }{8: 4│>>}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ {7: }{8: 4│}{102:>>}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: 4│}{7: }{8: }aaaaaa |
- {7: }{8: 5│}{1:>!}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ {7: }{8: 5│}{103:>!}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: 5│}{7: }{8: }aaaaaa |
- {7: }{8: 6│}{1:>!}{8:>> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ {7: }{8: 6│}{103:>!}{102:>>}{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: 6│}{7: }{8: }aaaaaa |
{7: }{8: 7│}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: 7│}{7: }{8: }aaaaaa |
@@ -336,11 +348,11 @@ describe('statuscolumn', function()
-- v:relnum is the same value on wrapped lines
command([[set stc=%C%=\ %{v:relnum}│%s\ ]])
screen:expect([[
- {7: }{8: 4│>>}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ {7: }{8: 4│}{102:>>}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: 4│}{7: }{8: }aaaaaaa |
- {7: }{8: 3│}{1:>!}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ {7: }{8: 3│}{103:>!}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: 3│}{7: }{8: }aaaaaaa |
- {7: }{8: 2│}{1:>!}{8:>> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ {7: }{8: 2│}{103:>!}{102:>>}{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: 2│}{7: }{8: }aaaaaaa |
{7: }{8: 1│}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: 1│}{7: }{8: }aaaaaaa |
@@ -353,11 +365,11 @@ describe('statuscolumn', function()
]])
command([[set stc=%C%=\ %{v:virtnum?'':v:relnum}│%s\ ]])
screen:expect([[
- {7: }{8: 4│>>}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ {7: }{8: 4│}{102:>>}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: │}{7: }{8: }aaaaaaa |
- {7: }{8: 3│}{1:>!}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ {7: }{8: 3│}{103:>!}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: │}{7: }{8: }aaaaaaa |
- {7: }{8: 2│}{1:>!}{8:>> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ {7: }{8: 2│}{103:>!}{102:>>}{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: │}{7: }{8: }aaaaaaa |
{7: }{8: 1│}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: │}{7: }{8: }aaaaaaa |
@@ -378,11 +390,11 @@ describe('statuscolumn', function()
command('sign place 10 line=6 name=piet2 buffer=1')
command('sign place 11 line=6 name=piet1 buffer=1')
screen:expect([[
- {7: }{8: 4│>>}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ {7: }{8: 4│}{102:>>}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: │}{7: }{8: }aaaaaaaaaaaaaaaaaaaaa |
- {7: }{8: 3│}{1:>!}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ {7: }{8: 3│}{103:>!}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: │}{7: }{8: }aaaaaaaaaaaaaaaaaaaaa |
- {7: }{8: 2│>>}{1:>!}{8:>>}{1:>!}{8:>>}{1:>!}{8:>>}{1:>!}{8:>> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ {7: }{8: 2│}{102:>>}{103:>!}{102:>>}{103:>!}{102:>>}{103:>!}{102:>>}{103:>!}{102:>>}{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: │}{7: }{8: }aaaaaaaaaaaaaaaaaaaaa |
{7: }{8: 1│}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: │}{7: }{8: }aaaaaaaaaaaaaaaaaaaaa |
@@ -397,11 +409,11 @@ describe('statuscolumn', function()
command('set cpoptions+=n')
feed('Hgjg0')
screen:expect([[
- {7: }{15: 0│}{8:>>}{7: }{15: }{19:aaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
+ {7: }{15: 0│}{102:>>}{7: }{15: }{19:aaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{7: }{19:^aaaaaaaaaaaaaaaaaaaaa }|
- {7: }{8: 3│}{1:>!}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ {7: }{8: 3│}{103:>!}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }aaaaaaaaaaaaaaaaaaaaa |
- {7: }{8: 2│>>}{1:>!}{8:>>}{1:>!}{8:>>}{1:>!}{8:>>}{1:>!}{8:>> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ {7: }{8: 2│}{102:>>}{103:>!}{102:>>}{103:>!}{102:>>}{103:>!}{102:>>}{103:>!}{102:>>}{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }aaaaaaaaaaaaaaaaaaaaa |
{7: }{8: 1│}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }aaaaaaaaaaaaaaaaaaaaa |
@@ -416,11 +428,11 @@ describe('statuscolumn', function()
command('sign unplace 2')
feed('J2gjg0')
screen:expect([[
- {7: }{15: 0│}{8:>>}{7: }{15: }{19:aaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
+ {7: }{15: 0│}{102:>>}{7: }{15: }{19:aaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{7: } {19:aaaaaaaaaaaaaaaaaaaaa aaaaaaa}|
{7: } {19:aaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{7: } {19:^aaaaaaaaaaaaaa }|
- {7: }{8: 1│>>}{1:>!}{8:>>}{1:>!}{8:>>}{1:>!}{8:>>}{1:>!}{8:>> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ {7: }{8: 1│}{102:>>}{103:>!}{102:>>}{103:>!}{102:>>}{103:>!}{102:>>}{103:>!}{102:>>}{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: } aaaaaaaaaaaaaaaaaaaaa |
{7: }{8: 2│}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: } aaaaaaaaaaaaaaaaaaaaa |
@@ -434,11 +446,11 @@ describe('statuscolumn', function()
command('set nobreakindent')
feed('$g0')
screen:expect([[
- {7: }{15: 0│}{8:>>}{7: }{15: }{19:aaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
+ {7: }{15: 0│}{102:>>}{7: }{15: }{19:aaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{7: }{19:aaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaa}|
{7: }{19:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{7: }{19:^aaaa }|
- {7: }{8: 1│>>}{1:>!}{8:>>}{1:>!}{8:>>}{1:>!}{8:>>}{1:>!}{8:>> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ {7: }{8: 1│}{102:>>}{103:>!}{102:>>}{103:>!}{102:>>}{103:>!}{102:>>}{103:>!}{102:>>}{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }aaaaaaaaaaaaaaaaaaaaa |
{7: }{8: 2│}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }aaaaaaaaaaaaaaaaaaaaa |
@@ -460,11 +472,11 @@ describe('statuscolumn', function()
]])
command('set foldcolumn=0 signcolumn=number stc=%l')
screen:expect([[
- {8:>>}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
+ {102:>>}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
{8: 5}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
{8: }virt_line |
{8: }virt_line above |
- {8:>>}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
+ {102:>>}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
{8: 7}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
{15: 8}{100:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{8: 9}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
@@ -580,13 +592,13 @@ describe('statuscolumn', function()
command([[set stc=%6s\ %l]])
exec_lua('vim.api.nvim_buf_set_extmark(0, ns, 7, 0, {sign_text = "𒀀"})')
screen:expect([[
- {8: 𒀀 8}^aaaaa |
+ {8: }{7:𒀀 }{8: 8}^aaaaa |
{8: }{7: }{8: 9}aaaaa |
|
]])
end)
- for _, model in ipairs(mousemodels) do
+ for _, model in ipairs({ 'extend', 'popup', 'popup_setpos' }) do
describe('with mousemodel=' .. model, function()
before_each(function()
command('set mousemodel=' .. model)
@@ -645,23 +657,56 @@ describe('statuscolumn', function()
-- Check that statusline click doesn't register as statuscolumn click
api.nvim_input_mouse('right', 'press', '', 0, 12, 0)
eq('', eval('g:testvar'))
+ -- Check that rightclick still opens popupmenu if there is no clickdef
+ if model == 'popup' then
+ api.nvim_set_option_value('statuscolumn', '%0@MyClickFunc@%=%l%TNoClick', {})
+ api.nvim_input_mouse('right', 'press', '', 0, 1, 0)
+ screen:expect([[
+ {5:[No Name] }|
+ {8: 4NoClick}^aaaaa |
+ {8: 5NoClick}aaaaa |
+ {8: 6NoClick}aaaaa |
+ {8: 7NoClick}aaaaa |
+ {8: 8NoClick}aaaaa |
+ {8: 9NoClick}aaaaa |
+ {8:10NoClick}aaaaa |
+ {8:11NoClick}aaaaa |
+ {8:12NoClick}aaaaa |
+ {8:13NoClick}aaaaa |
+ {8:14NoClick}aaaaa |
+ {3:[No Name] [+] }|
+ |
+ ]])
+ api.nvim_input_mouse('right', 'press', '', 0, 1, 3)
+ screen:expect([[
+ {5:[No Name] }|
+ {8: 4NoClick}^aaaaa |
+ {8: 5}{4: Inspect } |
+ {8: 6}{4: } |
+ {8: 7}{4: Paste } |
+ {8: 8}{4: Select All } |
+ {8: 9}{4: } |
+ {8:10}{4: How-to disable mouse } |
+ {8:11NoClick}aaaaa |
+ {8:12NoClick}aaaaa |
+ {8:13NoClick}aaaaa |
+ {8:14NoClick}aaaaa |
+ {3:[No Name] [+] }|
+ |
+ ]])
+ end
end)
it('clicks and highlights work with control characters', function()
api.nvim_set_option_value('statuscolumn', '\t%#NonText#\1%0@MyClickFunc@\t\1%T\t%##\1', {})
- screen:expect {
- grid = [[
- {1:^I}{0:^A^I^A^I}{1:^A}aaaaa |*4
- {1:^I}{0:^A^I^A^I}{1:^A}^aaaaa |
- {1:^I}{0:^A^I^A^I}{1:^A}aaaaa |*8
+ screen:expect([[
+ {8:^I}{1:^A^I^A^I}{8:^A}aaaaa |*4
+ {8:^I}{1:^A^I^A^I}{8:^A}^aaaaa |
+ {8:^I}{1:^A^I^A^I}{8:^A}aaaaa |*8
|
- ]],
- attr_ids = {
- [0] = { foreground = Screen.colors.Blue, bold = true }, -- NonText
- [1] = { foreground = Screen.colors.Brown }, -- LineNr
- },
- }
+ ]])
api.nvim_input_mouse('right', 'press', '', 0, 4, 3)
+ feed('<Esc>') -- Close popupmenu
eq('', eval('g:testvar'))
api.nvim_input_mouse('left', 'press', '', 0, 5, 8)
eq('', eval('g:testvar'))
@@ -707,6 +752,36 @@ describe('statuscolumn', function()
|
]])
end)
+
+ it('foldcolumn item can be clicked', function()
+ api.nvim_set_option_value('statuscolumn', '|%C|', {})
+ api.nvim_set_option_value('foldcolumn', '2', {})
+ api.nvim_set_option_value('mousetime', 0, {})
+ feed('ggzfjzfjzo')
+ local s1 = [[
+ {8:|}{7:-+}{8:|}{13:^+--- 2 lines: aaaaa·····························}|
+ {8:|}{7:│ }{8:|}aaaaa |
+ {8:|}{7: }{8:|}aaaaa |*11
+ |
+ ]]
+ screen:expect(s1)
+ api.nvim_input_mouse('left', 'press', '', 0, 0, 2)
+ screen:expect([[
+ {8:|}{7:--}{8:|}^aaaaa |
+ {8:|}{7:││}{8:|}aaaaa |
+ {8:|}{7:│ }{8:|}aaaaa |
+ {8:|}{7: }{8:|}aaaaa |*10
+ |
+ ]])
+ api.nvim_input_mouse('left', 'press', '', 0, 0, 1)
+ screen:expect(s1)
+ api.nvim_input_mouse('left', 'press', '', 0, 0, 1)
+ screen:expect([[
+ {8:|}{7:+ }{8:|}{13:^+-- 3 lines: aaaaa······························}|
+ {8:|}{7: }{8:|}aaaaa |*12
+ |
+ ]])
+ end)
end)
end
diff --git a/test/functional/ui/statusline_spec.lua b/test/functional/ui/statusline_spec.lua
index 1d0f181244..50e31ac6a9 100644
--- a/test/functional/ui/statusline_spec.lua
+++ b/test/functional/ui/statusline_spec.lua
@@ -507,268 +507,263 @@ describe('global statusline', function()
end)
end)
-it('statusline does not crash if it has Arabic characters #19447', function()
- clear()
- api.nvim_set_option_value('statusline', 'غً', {})
- api.nvim_set_option_value('laststatus', 2, {})
- command('redraw!')
- assert_alive()
-end)
+describe('statusline', function()
+ local screen
+ before_each(function()
+ clear()
+ screen = Screen.new(40, 8)
+ screen:add_extra_attr_ids {
+ [100] = { bold = true, reverse = true, foreground = Screen.colors.Blue },
+ [101] = { reverse = true, bold = true, foreground = Screen.colors.SlateBlue },
+ }
+ end)
-it('statusline is redrawn with :resize from <Cmd> mapping #19629', function()
- clear()
- local screen = Screen.new(40, 8)
- exec([[
- set laststatus=2
- nnoremap <Up> <cmd>resize -1<CR>
- nnoremap <Down> <cmd>resize +1<CR>
- ]])
- feed('<Up>')
- screen:expect([[
- ^ |
- {1:~ }|*4
- {3:[No Name] }|
- |*2
- ]])
- feed('<Down>')
- screen:expect([[
- ^ |
- {1:~ }|*5
- {3:[No Name] }|
- |
- ]])
-end)
+ it('does not crash if it has Arabic characters #19447', function()
+ api.nvim_set_option_value('statusline', 'غً', {})
+ api.nvim_set_option_value('laststatus', 2, {})
+ command('redraw!')
+ assert_alive()
+ end)
-it('showcmdloc=statusline does not show if statusline is too narrow', function()
- clear()
- local screen = Screen.new(40, 8)
- command('set showcmd')
- command('set showcmdloc=statusline')
- command('1vsplit')
- screen:expect([[
- ^ │ |
- {1:~}│{1:~ }|*5
- {3:< }{2:[No Name] }|
- |
- ]])
- feed('1234')
- screen:expect_unchanged()
-end)
+ it('is redrawn with :resize from <Cmd> mapping #19629', function()
+ exec([[
+ set laststatus=2
+ nnoremap <Up> <cmd>resize -1<CR>
+ nnoremap <Down> <cmd>resize +1<CR>
+ ]])
+ feed('<Up>')
+ screen:expect([[
+ ^ |
+ {1:~ }|*4
+ {3:[No Name] }|
+ |*2
+ ]])
+ feed('<Down>')
+ screen:expect([[
+ ^ |
+ {1:~ }|*5
+ {3:[No Name] }|
+ |
+ ]])
+ end)
-it('K_EVENT does not trigger a statusline redraw unnecessarily', function()
- clear()
- local _ = Screen.new(40, 8)
- -- does not redraw on vim.schedule (#17937)
- command([[
- set laststatus=2
- let g:counter = 0
- func Status()
- let g:counter += 1
- lua vim.schedule(function() end)
- return g:counter
- endfunc
- set statusline=%!Status()
- ]])
- sleep(50)
- eq(1, eval('g:counter < 50'), 'g:counter=' .. eval('g:counter'))
- -- also in insert mode
- feed('i')
- sleep(50)
- eq(1, eval('g:counter < 50'), 'g:counter=' .. eval('g:counter'))
- -- does not redraw on timer call (#14303)
- command([[
- let g:counter = 0
- func Timer(timer)
- endfunc
- call timer_start(1, 'Timer', {'repeat': 100})
- ]])
- sleep(50)
- eq(1, eval('g:counter < 50'), 'g:counter=' .. eval('g:counter'))
-end)
+ it('does not contain showmcd with showcmdloc=statusline when too narrow', function()
+ command('set showcmd')
+ command('set showcmdloc=statusline')
+ command('1vsplit')
+ screen:expect([[
+ ^ │ |
+ {1:~}│{1:~ }|*5
+ {3:< }{2:[No Name] }|
+ |
+ ]])
+ feed('1234')
+ screen:expect_unchanged()
+ end)
-it('statusline is redrawn on various state changes', function()
- clear()
- local screen = Screen.new(40, 4)
-
- -- recording state change #22683
- command('set ls=2 stl=%{repeat(reg_recording(),5)}')
- screen:expect([[
- ^ |
- {1:~ }|
- {3: }|
- |
- ]])
- feed('qQ')
- screen:expect([[
- ^ |
- {1:~ }|
- {3:QQQQQ }|
- {5:recording @Q} |
- ]])
- feed('q')
- screen:expect([[
- ^ |
- {1:~ }|
- {3: }|
- |
- ]])
-
- -- Visual mode change #23932
- command('set ls=2 stl=%{mode(1)}')
- screen:expect([[
- ^ |
- {1:~ }|
- {3:n }|
- |
- ]])
- feed('v')
- screen:expect([[
- ^ |
- {1:~ }|
- {3:v }|
- {5:-- VISUAL --} |
- ]])
- feed('V')
- screen:expect([[
- ^ |
- {1:~ }|
- {3:V }|
- {5:-- VISUAL LINE --} |
- ]])
- feed('<C-V>')
- screen:expect([[
- ^ |
- {1:~ }|
- {3:^V }|
- {5:-- VISUAL BLOCK --} |
- ]])
- feed('<Esc>')
- screen:expect([[
- ^ |
- {1:~ }|
- {3:n }|
- |
- ]])
-end)
+ it('does not redraw unnecessarily after K_EVENT', function()
+ -- does not redraw on vim.schedule (#17937)
+ command([[
+ set laststatus=2
+ let g:counter = 0
+ func Status()
+ let g:counter += 1
+ lua vim.schedule(function() end)
+ return g:counter
+ endfunc
+ set statusline=%!Status()
+ ]])
+ sleep(50)
+ eq(1, eval('g:counter < 50'), 'g:counter=' .. eval('g:counter'))
+ -- also in insert mode
+ feed('i')
+ sleep(50)
+ eq(1, eval('g:counter < 50'), 'g:counter=' .. eval('g:counter'))
+ -- does not redraw on timer call (#14303)
+ command([[
+ let g:counter = 0
+ func Timer(timer)
+ endfunc
+ call timer_start(1, 'Timer', {'repeat': 100})
+ ]])
+ sleep(50)
+ eq(1, eval('g:counter < 50'), 'g:counter=' .. eval('g:counter'))
+ end)
-it('ruler is redrawn in cmdline with redrawstatus #22804', function()
- clear()
- local screen = Screen.new(40, 2)
- command([[
- let g:n = 'initial value'
- set ls=1 ru ruf=%{g:n}
- redraw
- let g:n = 'other value'
- redrawstatus
- ]])
- screen:expect([[
- ^ |
- other value |
- ]])
-end)
+ it('is redrawn on various state changes', function()
+ -- recording state change #22683
+ command('set ls=2 stl=%{repeat(reg_recording(),5)}')
+ local s1 = [[
+ ^ |
+ {1:~ }|*5
+ {3: }|
+ |
+ ]]
+ screen:expect(s1)
+ feed('qQ')
+ screen:expect([[
+ ^ |
+ {1:~ }|*5
+ {3:QQQQQ }|
+ {5:recording @Q} |
+ ]])
+ feed('q')
+ screen:expect(s1)
+
+ -- Visual mode change #23932
+ command('set ls=2 stl=%{mode(1)}')
+ local s2 = [[
+ ^ |
+ {1:~ }|*5
+ {3:n }|
+ |
+ ]]
+ screen:expect(s2)
+ feed('v')
+ screen:expect([[
+ ^ |
+ {1:~ }|*5
+ {3:v }|
+ {5:-- VISUAL --} |
+ ]])
+ feed('V')
+ screen:expect([[
+ ^ |
+ {1:~ }|*5
+ {3:V }|
+ {5:-- VISUAL LINE --} |
+ ]])
+ feed('<C-V>')
+ screen:expect([[
+ ^ |
+ {1:~ }|*5
+ {3:^V }|
+ {5:-- VISUAL BLOCK --} |
+ ]])
+ feed('<Esc>')
+ screen:expect(s2)
+ end)
-it('shows correct ruler in cmdline with no statusline', function()
- clear()
- local screen = Screen.new(30, 8)
- -- Use long ruler to check 'ruler' with 'rulerformat' set has correct width.
- command [[
- set ruler rulerformat=%{winnr()}longlonglong ls=0 winwidth=10
- split
- wincmd b
- vsplit
- wincmd t
- wincmd |
- mode
- ]]
- -- Window 1 is current. It has a statusline, so cmdline should show the
- -- last window's ruler, which has no statusline.
- command '1wincmd w'
- screen:expect [[
- ^ |
- {1:~ }|*2
- {3:[No Name] 1longlonglong }|
- │ |
- {1:~ }│{1:~ }|*2
- 3longlonglong |
- ]]
- -- Window 2 is current. It has no statusline, so cmdline should show its
- -- ruler instead.
- command '2wincmd w'
- screen:expect [[
- |
- {1:~ }|*2
- {2:[No Name] 1longlonglong }|
- ^ │ |
- {1:~ }│{1:~ }|*2
- 2longlonglong |
- ]]
- -- Window 3 is current. Cmdline should again show its ruler.
- command '3wincmd w'
- screen:expect [[
- |
- {1:~ }|*2
- {2:[No Name] 1longlonglong }|
- │^ |
- {1:~ }│{1:~ }|*2
- 3longlonglong |
- ]]
-end)
+ it('ruler is redrawn in cmdline with redrawstatus #22804', function()
+ command([[
+ let g:n = 'initial value'
+ set ls=1 ru ruf=%{g:n}
+ redraw
+ let g:n = 'other value'
+ redrawstatus
+ ]])
+ screen:expect([[
+ ^ |
+ {1:~ }|*6
+ other value |
+ ]])
+ end)
-it('uses "stl" and "stlnc" fillchars even if they are the same #19803', function()
- clear()
- local screen = Screen.new(53, 4)
- command('hi clear StatusLine')
- command('hi clear StatusLineNC')
- command('vsplit')
- screen:expect {
- grid = [[
- ^ │ |
- {1:~ }│{1:~ }|
- [No Name] [No Name] |
- |
- ]],
- }
-end)
+ it('hidden moves ruler to cmdline', function()
+ -- Use long ruler to check 'ruler' with 'rulerformat' set has correct width.
+ command [[
+ set ruler rulerformat=%{winnr()}longlonglong ls=0 winwidth=10
+ split
+ wincmd b
+ vsplit
+ wincmd t
+ wincmd |
+ mode
+ ]]
+ -- Window 1 is current. It has a statusline, so cmdline should show the
+ -- last window's ruler, which has no statusline.
+ command '1wincmd w'
+ screen:expect([[
+ ^ |
+ {1:~ }|*2
+ {3:[No Name] 1longlonglong }|
+ │ |
+ {1:~ }│{1:~ }|*2
+ 3longlonglong |
+ ]])
+ -- Window 2 is current. It has no statusline, so cmdline should show its
+ -- ruler instead.
+ command '2wincmd w'
+ screen:expect([[
+ |
+ {1:~ }|*2
+ {2:[No Name] 1longlonglong }|
+ ^ │ |
+ {1:~ }│{1:~ }|*2
+ 2longlonglong |
+ ]])
+ -- Window 3 is current. Cmdline should again show its ruler.
+ command '3wincmd w'
+ screen:expect([[
+ |
+ {1:~ }|*2
+ {2:[No Name] 1longlonglong }|
+ │^ |
+ {1:~ }│{1:~ }|*2
+ 3longlonglong |
+ ]])
+ end)
-it('showcmdloc=statusline works with vertical splits', function()
- clear()
- local screen = Screen.new(53, 4)
- command('rightbelow vsplit')
- command('set showcmd showcmdloc=statusline')
- feed('1234')
- screen:expect([[
- │^ |
- {1:~ }│{1:~ }|
- {2:[No Name] }{3:[No Name] 1234 }|
- |
- ]])
- feed('<Esc>')
- command('set laststatus=3')
- feed('1234')
- screen:expect([[
- │^ |
- {1:~ }│{1:~ }|
- {3:[No Name] 1234 }|
- |
- ]])
-end)
+ it('uses "stl" and "stlnc" fillchars even if they are the same #19803', function()
+ command('hi clear StatusLine')
+ command('hi clear StatusLineNC')
+ command('vsplit')
+ screen:expect([[
+ ^ │ |
+ {1:~ }│{1:~ }|*5
+ [No Name] [No Name] |
+ |
+ ]])
+ end)
-it('keymap is shown with vertical splits #27269', function()
- clear()
- local screen = Screen.new(53, 4)
- command('setlocal keymap=dvorak')
- command('rightbelow vsplit')
- screen:expect([[
- │^ |
- {1:~ }│{1:~ }|
- {2:[No Name] <en-dv> }{3:[No Name] <en-dv> }|
- |
- ]])
- command('set laststatus=3')
- screen:expect([[
- │^ |
- {1:~ }│{1:~ }|
- {3:[No Name] <en-dv> }|
- |
- ]])
+ it('showcmdloc=statusline works with vertical splits', function()
+ command('rightbelow vsplit')
+ command('set showcmd showcmdloc=statusline')
+ feed('1234')
+ screen:expect([[
+ │^ |
+ {1:~ }│{1:~ }|*5
+ {2:[No Name] }{3:[No Name] 1234 }|
+ |
+ ]])
+ feed('<Esc>')
+ command('set laststatus=3')
+ feed('1234')
+ screen:expect([[
+ │^ |
+ {1:~ }│{1:~ }|*5
+ {3:[No Name] 1234 }|
+ |
+ ]])
+ end)
+
+ it('keymap is shown with vertical splits #27269', function()
+ command('setlocal keymap=dvorak')
+ command('rightbelow vsplit')
+ screen:expect([[
+ │^ |
+ {1:~ }│{1:~ }|*5
+ {2:[No Name] <en-dv> }{3:[No Name] <en-dv> }|
+ |
+ ]])
+
+ command('set laststatus=3')
+ screen:expect([[
+ │^ |
+ {1:~ }│{1:~ }|*5
+ {3:[No Name] <en-dv> }|
+ |
+ ]])
+ end)
+
+ it("nested call from nvim_eval_statusline() doesn't overwrite items #32259", function()
+ exec_lua('vim.o.laststatus = 2')
+ exec_lua([[vim.o.statusline = '%#Special#B:%{nvim_eval_statusline("%f", []).str}']])
+ screen:expect([[
+ ^ |
+ {1:~ }|*5
+ {101:B:[No Name] }|
+ |
+ ]])
+ end)
end)
diff --git a/test/functional/ui/syntax_conceal_spec.lua b/test/functional/ui/syntax_conceal_spec.lua
index 57d76e54df..80e38d974a 100644
--- a/test/functional/ui/syntax_conceal_spec.lua
+++ b/test/functional/ui/syntax_conceal_spec.lua
@@ -198,7 +198,7 @@ describe('Screen', function()
end)
end) -- a region of text (implicit concealing)
- it('cursor position is correct when entering Insert mode with cocu=ni #13916', function()
+ it('cursor position when entering Insert mode with cocu=ni #13916', function()
insert([[foobarfoobarfoobar]])
-- move to end of line
feed('$')
@@ -217,6 +217,37 @@ describe('Screen', function()
{4:-- INSERT --} |
]])
end)
+
+ it('cursor position when scrolling in Normal mode with cocu=n #31271', function()
+ insert(('foo\n'):rep(9) .. 'foofoobarfoofoo' .. ('\nfoo'):rep(9))
+ command('set concealcursor=n')
+ command('syn match Foo /bar/ conceal cchar=&')
+ feed('gg5<C-E>10gg$')
+ screen:expect([[
+ foo |*4
+ foofoo{1:&}foofo^o |
+ foo |*4
+ |
+ ]])
+ feed('zz')
+ screen:expect_unchanged()
+ feed('zt')
+ screen:expect([[
+ foofoo{1:&}foofo^o |
+ foo |*8
+ |
+ ]])
+ feed('zt')
+ screen:expect_unchanged()
+ feed('zb')
+ screen:expect([[
+ foo |*8
+ foofoo{1:&}foofo^o |
+ |
+ ]])
+ feed('zb')
+ screen:expect_unchanged()
+ end)
end) -- match and conceal
describe('let the conceal level be', function()
diff --git a/test/functional/ui/title_spec.lua b/test/functional/ui/title_spec.lua
index 66eb15478b..2de1e71457 100644
--- a/test/functional/ui/title_spec.lua
+++ b/test/functional/ui/title_spec.lua
@@ -37,6 +37,63 @@ describe('title', function()
end)
end)
+ it('is updated in Insert mode', function()
+ api.nvim_set_option_value('title', true, {})
+ screen:expect(function()
+ eq('[No Name] - Nvim', screen.title)
+ end)
+ feed('ifoo')
+ screen:expect(function()
+ eq('[No Name] + - Nvim', screen.title)
+ end)
+ feed('<Esc>')
+ api.nvim_set_option_value('titlestring', '%m %f (%{mode(1)}) | nvim', {})
+ screen:expect(function()
+ eq('[+] [No Name] (n) | nvim', screen.title)
+ end)
+ feed('i')
+ screen:expect(function()
+ eq('[+] [No Name] (i) | nvim', screen.title)
+ end)
+ feed('<Esc>')
+ screen:expect(function()
+ eq('[+] [No Name] (n) | nvim', screen.title)
+ end)
+ end)
+
+ it('is updated in Cmdline mode', function()
+ api.nvim_set_option_value('title', true, {})
+ api.nvim_set_option_value('titlestring', '%f (%{mode(1)}) | nvim', {})
+ screen:expect(function()
+ eq('[No Name] (n) | nvim', screen.title)
+ end)
+ feed(':')
+ screen:expect(function()
+ eq('[No Name] (c) | nvim', screen.title)
+ end)
+ feed('<Esc>')
+ screen:expect(function()
+ eq('[No Name] (n) | nvim', screen.title)
+ end)
+ end)
+
+ it('is updated in Terminal mode', function()
+ api.nvim_set_option_value('title', true, {})
+ api.nvim_set_option_value('titlestring', '(%{mode(1)}) | nvim', {})
+ fn.jobstart({ n.testprg('shell-test'), 'INTERACT' }, { term = true })
+ screen:expect(function()
+ eq('(nt) | nvim', screen.title)
+ end)
+ feed('i')
+ screen:expect(function()
+ eq('(t) | nvim', screen.title)
+ end)
+ feed([[<C-\><C-N>]])
+ screen:expect(function()
+ eq('(nt) | nvim', screen.title)
+ end)
+ end)
+
describe('is not changed by', function()
local file1 = is_os('win') and 'C:\\mydir\\myfile1' or '/mydir/myfile1'
local file2 = is_os('win') and 'C:\\mydir\\myfile2' or '/mydir/myfile2'