commit bea87b4a9e27deab1350c65f740768439e199274
parent 18f24b85c34a4d431bccf5ea545f8b168917fcd9
Author: zeertzjq <zeertzjq@outlook.com>
Date: Mon, 8 Sep 2025 08:43:15 +0800
test: add tests for #20348
Diffstat:
3 files changed, 43 insertions(+), 3 deletions(-)
diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c
@@ -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)
{
diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua
@@ -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)
diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua
@@ -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