Skip to content

Commit bea87b4

Browse files
committed
test: add tests for neovim#20348
1 parent 18f24b8 commit bea87b4

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-3
lines changed

src/nvim/cmdexpand.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ int nextwild(expand_T *xp, int type, int options, bool escape)
381381
return OK;
382382
}
383383

384-
/// Create completion popup menu with items from 'matches'.
384+
/// Create completion popup menu with items from "matches".
385385
static int cmdline_pum_create(CmdlineInfo *ccline, expand_T *xp, char **matches, int numMatches,
386386
bool showtail, bool noselect)
387387
{

test/functional/ui/cmdline_spec.lua

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,12 +535,40 @@ local function test_cmdline(linegrid)
535535
{2:långfile1 }|
536536
|
537537
]],
538+
cmdline = { { content = { { 'b långfile1' } }, firstc = ':', pos = 12 } },
538539
popupmenu = {
539540
anchor = { -1, 0, 2 },
540541
items = { { 'långfile1', '', '', '' }, { 'långfile2', '', '', '' } },
541542
pos = 0,
542543
},
543-
cmdline = { { content = { { 'b långfile1' } }, firstc = ':', pos = 12 } },
544+
}
545+
546+
feed('<Esc>')
547+
command('silent %bwipe')
548+
549+
command('set shellslash')
550+
-- position is correct when expanding environment variable #20348
551+
command('silent cd test/functional/fixtures')
552+
n.fn.setenv('XNDIR', 'wildpum/Xnamedir')
553+
feed(':e $XNDIR/<Tab>')
554+
screen:expect {
555+
grid = [[
556+
^ |
557+
{1:~ }|*3
558+
|
559+
]],
560+
cmdline = {
561+
{
562+
content = { { 'e wildpum/Xnamedir/XdirA/' } },
563+
firstc = ':',
564+
pos = 25,
565+
},
566+
},
567+
popupmenu = {
568+
anchor = { -1, 0, 19 },
569+
items = { { 'XdirA/', '', '', '' }, { 'XfileA', '', '', '' } },
570+
pos = 0,
571+
},
544572
}
545573
end)
546574

test/functional/ui/popupmenu_spec.lua

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4853,7 +4853,7 @@ describe('builtin popupmenu', function()
48534853
]])
48544854

48554855
feed('<esc>')
4856-
command('close')
4856+
command('%bwipe')
48574857
command('set wildmode=full')
48584858

48594859
-- special case: when patterns ends with "/", show menu items aligned
@@ -4866,6 +4866,18 @@ describe('builtin popupmenu', function()
48664866
{1:~ }{n: file2 }{1: }|
48674867
:e compdir/file1^ |
48684868
]])
4869+
4870+
-- position is correct when expanding environment variable #20348
4871+
command('cd ..')
4872+
fn.setenv('XNDIR', 'wildpum/Xnamedir')
4873+
feed('<C-U>e $XNDIR/<Tab>')
4874+
screen:expect([[
4875+
|
4876+
{1:~ }|*11
4877+
{1:~ }{12: XdirA/ }{1: }|
4878+
{1:~ }{n: XfileA }{1: }|
4879+
:e wildpum/Xnamedir/XdirA/^ |
4880+
]])
48694881
end)
48704882
end
48714883

0 commit comments

Comments
 (0)