test: add tests for #20348

This commit is contained in:
zeertzjq
2025-09-08 08:43:15 +08:00
parent 18f24b85c3
commit bea87b4a9e
3 changed files with 43 additions and 3 deletions

View File

@@ -381,7 +381,7 @@ int nextwild(expand_T *xp, int type, int options, bool escape)
return OK;
}
/// Create completion popup menu with items from 'matches'.
/// Create completion popup menu with items from "matches".
static int cmdline_pum_create(CmdlineInfo *ccline, expand_T *xp, char **matches, int numMatches,
bool showtail, bool noselect)
{

View File

@@ -535,12 +535,40 @@ local function test_cmdline(linegrid)
{2:långfile1 }|
|
]],
cmdline = { { content = { { 'b långfile1' } }, firstc = ':', pos = 12 } },
popupmenu = {
anchor = { -1, 0, 2 },
items = { { 'långfile1', '', '', '' }, { 'långfile2', '', '', '' } },
pos = 0,
},
cmdline = { { content = { { 'b långfile1' } }, firstc = ':', pos = 12 } },
}
feed('<Esc>')
command('silent %bwipe')
command('set shellslash')
-- position is correct when expanding environment variable #20348
command('silent cd test/functional/fixtures')
n.fn.setenv('XNDIR', 'wildpum/Xnamedir')
feed(':e $XNDIR/<Tab>')
screen:expect {
grid = [[
^ |
{1:~ }|*3
|
]],
cmdline = {
{
content = { { 'e wildpum/Xnamedir/XdirA/' } },
firstc = ':',
pos = 25,
},
},
popupmenu = {
anchor = { -1, 0, 19 },
items = { { 'XdirA/', '', '', '' }, { 'XfileA', '', '', '' } },
pos = 0,
},
}
end)

View File

@@ -4853,7 +4853,7 @@ describe('builtin popupmenu', function()
]])
feed('<esc>')
command('close')
command('%bwipe')
command('set wildmode=full')
-- special case: when patterns ends with "/", show menu items aligned
@@ -4866,6 +4866,18 @@ describe('builtin popupmenu', function()
{1:~ }{n: file2 }{1: }|
:e compdir/file1^ |
]])
-- position is correct when expanding environment variable #20348
command('cd ..')
fn.setenv('XNDIR', 'wildpum/Xnamedir')
feed('<C-U>e $XNDIR/<Tab>')
screen:expect([[
|
{1:~ }|*11
{1:~ }{12: XdirA/ }{1: }|
{1:~ }{n: XfileA }{1: }|
:e wildpum/Xnamedir/XdirA/^ |
]])
end)
end