diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c index 3ce314f1d9..b6a0047cf6 100644 --- a/src/nvim/cmdexpand.c +++ b/src/nvim/cmdexpand.c @@ -249,13 +249,14 @@ int nextwild(expand_T *xp, int type, int options, bool escape) char *p; if (xp->xp_numfiles == -1) { - may_expand_pattern = options & WILD_MAY_EXPAND_PATTERN; pre_incsearch_pos = xp->xp_pre_incsearch_pos; if (ccline->input_fn && ccline->xp_context == EXPAND_COMMANDS) { // Expand commands typed in input() function set_cmd_context(xp, ccline->cmdbuff, ccline->cmdlen, ccline->cmdpos, false); } else { + may_expand_pattern = options & WILD_MAY_EXPAND_PATTERN; set_expand_context(xp); + may_expand_pattern = false; } if (xp->xp_context == EXPAND_LUA) { nlua_expand_pat(xp); diff --git a/test/old/testdir/test_cmdline.vim b/test/old/testdir/test_cmdline.vim index 1391f5be6e..a2ecc57388 100644 --- a/test/old/testdir/test_cmdline.vim +++ b/test/old/testdir/test_cmdline.vim @@ -4505,7 +4505,7 @@ func Test_search_complete() call feedkeys("gg/Fo\\", 'tx') call assert_equal(['Foobar', 'FooBARR'], g:compl_info.matches) call feedkeys("gg/FO\\", 'tx') - call assert_equal({}, g:compl_info) + call assert_equal({}, g:compl_info) call feedkeys("gg/\\cFo\\", 'tx') call assert_equal(['\cFoobar', '\cFooBAr', '\cFooBARR'], g:compl_info.matches) @@ -4525,7 +4525,12 @@ func Test_search_complete() call feedkeys("gg/Fo\\", 'tx') call assert_equal(['Foobar', 'FooBARR'], g:compl_info.matches) call feedkeys("gg/FO\\", 'tx') - call assert_equal({}, g:compl_info) + call assert_equal({}, g:compl_info) + + " Issue #17680 (getcompletion() does not support search completion) + let result = getcompletion('%s/', 'cmdline') + call assert_equal([], result) + call feedkeys("gg/foob\\", 'tx') call assert_equal(['foobar', 'foobarr'], g:compl_info.matches) call feedkeys("gg/\\Cfo\\", 'tx') @@ -4630,44 +4635,44 @@ func Test_range_complete() for trig in ["\", "\"] call feedkeys($":%s/a{trig}\", 'xt') - call assert_equal(['ab', 'a', 'af'], g:compl_info.matches) + call assert_equal(['ab', 'a', 'af'], g:compl_info.matches) " call feedkeys($":vim9cmd :%s/a{trig}\", 'xt') call feedkeys($":verbose :%s/a{trig}\", 'xt') - call assert_equal(['ab', 'a', 'af'], g:compl_info.matches) + call assert_equal(['ab', 'a', 'af'], g:compl_info.matches) endfor call feedkeys(":%s/\\", 'xt') - call assert_equal({}, g:compl_info) + call assert_equal({}, g:compl_info) for cmd in ['s', 'g'] - call feedkeys(":1,2" . cmd . "/a\\", 'xt') - call assert_equal(['ab', 'a'], g:compl_info.matches) + call feedkeys($":1,2{cmd}/a\\", 'xt') + call assert_equal(['ab', 'a'], g:compl_info.matches) endfor 1 call feedkeys(":.,+2s/a\\", 'xt') - call assert_equal(['ab', 'a'], g:compl_info.matches) + call assert_equal(['ab', 'a'], g:compl_info.matches) /f call feedkeys(":1,s/b\\", 'xt') - call assert_equal(['b', 'ba'], g:compl_info.matches) + call assert_equal(['b', 'ba'], g:compl_info.matches) /c call feedkeys(":\\?,4s/a\\", 'xt') - call assert_equal(['a', 'af'], g:compl_info.matches) + call assert_equal(['a', 'af'], g:compl_info.matches) %s/c/c/ call feedkeys(":1,\\&s/a\\", 'xt') - call assert_equal(['ab', 'a'], g:compl_info.matches) + call assert_equal(['ab', 'a'], g:compl_info.matches) 3 normal! ma call feedkeys(":'a,$s/a\\", 'xt') - call assert_equal(['a', 'af'], g:compl_info.matches) + call assert_equal(['a', 'af'], g:compl_info.matches) " Line number followed by a search pattern ([start]/pattern/[command]) call feedkeys("3/a\\", 'xt') - call assert_equal(['a', 'af', 'ab'], g:compl_info.matches) + call assert_equal(['a', 'af', 'ab'], g:compl_info.matches) bw! call Ntest_override("char_avail", 0)