mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
vim-patch:9.0.1636: expanding a pattern interferes with cmdline completion
Problem: Expanding a pattern interferes with command line completion. Solution: Set the file index only when appropriate. (closes vim/vim#12519)094dd152fe
(cherry picked from commita81b2b72c2
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
0f121fea81
commit
6ed84f8571
@@ -841,7 +841,7 @@ static char *find_longest_match(expand_T *xp, int options)
|
|||||||
char *ExpandOne(expand_T *xp, char *str, char *orig, int options, int mode)
|
char *ExpandOne(expand_T *xp, char *str, char *orig, int options, int mode)
|
||||||
{
|
{
|
||||||
char *ss = NULL;
|
char *ss = NULL;
|
||||||
static int findex;
|
static int findex; // TODO(vim): Move into expand_T
|
||||||
static char *orig_save = NULL; // kept value of orig
|
static char *orig_save = NULL; // kept value of orig
|
||||||
int orig_saved = false;
|
int orig_saved = false;
|
||||||
|
|
||||||
@@ -871,7 +871,10 @@ char *ExpandOne(expand_T *xp, char *str, char *orig, int options, int mode)
|
|||||||
cmdline_pum_remove();
|
cmdline_pum_remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
findex = 0;
|
// TODO(vim): Remove condition if "findex" is part of expand_T ?
|
||||||
|
if (mode != WILD_EXPAND_FREE && mode != WILD_ALL && mode != WILD_ALL_KEEP) {
|
||||||
|
findex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (mode == WILD_FREE) { // only release file name
|
if (mode == WILD_FREE) { // only release file name
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@@ -1253,6 +1253,30 @@ func Test_cmdline_complete_various()
|
|||||||
call assert_equal('"py3file', @:)
|
call assert_equal('"py3file', @:)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test that expanding a pattern doesn't interfere with cmdline completion.
|
||||||
|
func Test_expand_during_cmdline_completion()
|
||||||
|
func ExpandStuff()
|
||||||
|
badd <script>:p:h/README.*
|
||||||
|
call assert_equal(expand('<script>:p:h') .. '/README.txt', bufname('$'))
|
||||||
|
$bwipe
|
||||||
|
call assert_equal('README.txt', expand('README.*'))
|
||||||
|
call assert_equal(['README.txt'], getcompletion('README.*', 'file'))
|
||||||
|
endfunc
|
||||||
|
augroup test_CmdlineChanged
|
||||||
|
autocmd!
|
||||||
|
autocmd CmdlineChanged * call ExpandStuff()
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
call feedkeys(":sign \<Tab>\<Tab>\<Tab>\<Tab>\<C-B>\"\<CR>", 'xt')
|
||||||
|
call assert_equal('"sign place', @:)
|
||||||
|
|
||||||
|
augroup test_CmdlineChanged
|
||||||
|
au!
|
||||||
|
augroup END
|
||||||
|
augroup! test_CmdlineChanged
|
||||||
|
delfunc ExpandStuff
|
||||||
|
endfunc
|
||||||
|
|
||||||
" Test for 'wildignorecase'
|
" Test for 'wildignorecase'
|
||||||
func Test_cmdline_wildignorecase()
|
func Test_cmdline_wildignorecase()
|
||||||
CheckUnix
|
CheckUnix
|
||||||
@@ -1792,6 +1816,7 @@ func Test_cmd_bang_E135()
|
|||||||
augroup test_cmd_filter_E135
|
augroup test_cmd_filter_E135
|
||||||
au!
|
au!
|
||||||
augroup END
|
augroup END
|
||||||
|
augroup! test_cmd_filter_E135
|
||||||
%bwipe!
|
%bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@@ -2280,7 +2305,7 @@ endfunc
|
|||||||
func Test_cmd_map_cmdlineChanged()
|
func Test_cmd_map_cmdlineChanged()
|
||||||
let g:log = []
|
let g:log = []
|
||||||
cnoremap <F1> l<Cmd><CR>s
|
cnoremap <F1> l<Cmd><CR>s
|
||||||
augroup test
|
augroup test_CmdlineChanged
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd CmdlineChanged : let g:log += [getcmdline()]
|
autocmd CmdlineChanged : let g:log += [getcmdline()]
|
||||||
augroup END
|
augroup END
|
||||||
@@ -2296,9 +2321,10 @@ func Test_cmd_map_cmdlineChanged()
|
|||||||
|
|
||||||
unlet g:log
|
unlet g:log
|
||||||
cunmap <F1>
|
cunmap <F1>
|
||||||
augroup test
|
augroup test_CmdlineChanged
|
||||||
autocmd!
|
autocmd!
|
||||||
augroup END
|
augroup END
|
||||||
|
augroup! test_CmdlineChanged
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Test for the 'suffixes' option
|
" Test for the 'suffixes' option
|
||||||
|
Reference in New Issue
Block a user