aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui/cmdline_spec.lua
diff options
context:
space:
mode:
authorLuuk van Baal <luukvbaal@gmail.com>2024-12-20 21:11:38 +0100
committerLuuk van Baal <luukvbaal@gmail.com>2024-12-22 15:23:43 +0100
commit394f69a25dc32c5b101ba2d34ac6376b0c75b2a2 (patch)
tree8609bdc18c695c585a65a3c7733830ad87fa5a2d /test/functional/ui/cmdline_spec.lua
parente1c2179dd93ed2cd787b1cd016606b1901a1acfe (diff)
downloadrneovim-394f69a25dc32c5b101ba2d34ac6376b0c75b2a2.tar.gz
rneovim-394f69a25dc32c5b101ba2d34ac6376b0c75b2a2.tar.bz2
rneovim-394f69a25dc32c5b101ba2d34ac6376b0c75b2a2.zip
feat(ui): additional arguments for cmdline_show/hide events
Problem: Unable to tell what highlight the prompt part of a cmdline_show event should have, and whether cmdline_hide was emitted after aborting. Solution: Add additional arguments hl_id to cmdline_show, and abort to cmdline_hide.
Diffstat (limited to 'test/functional/ui/cmdline_spec.lua')
-rw-r--r--test/functional/ui/cmdline_spec.lua62
1 files changed, 50 insertions, 12 deletions
diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua
index 0221c1e0b0..63764a9b6c 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 = 237,
+ pos = 0,
+ prompt = 'Prompt:',
+ },
+ },
+ })
+ end)
end
-- the representation of cmdline and cmdline_block contents changed with ext_linegrid