mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
vim-patch:9.1.1528: completion: crash with getcompletion()
Problem: completion: crash with getcompletion()
(zeertzjq)
Solution: Don't set may_expand_pattern in f_getcompletion(),
unset may_expand_pattern() once it is not longer needed
(Girish Palya).
fixes: vim/vim#17680
closes: vim/vim#17686
f2ec8d4afc
Co-authored-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
@@ -249,13 +249,14 @@ int nextwild(expand_T *xp, int type, int options, bool escape)
|
|||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
if (xp->xp_numfiles == -1) {
|
if (xp->xp_numfiles == -1) {
|
||||||
may_expand_pattern = options & WILD_MAY_EXPAND_PATTERN;
|
|
||||||
pre_incsearch_pos = xp->xp_pre_incsearch_pos;
|
pre_incsearch_pos = xp->xp_pre_incsearch_pos;
|
||||||
if (ccline->input_fn && ccline->xp_context == EXPAND_COMMANDS) {
|
if (ccline->input_fn && ccline->xp_context == EXPAND_COMMANDS) {
|
||||||
// Expand commands typed in input() function
|
// Expand commands typed in input() function
|
||||||
set_cmd_context(xp, ccline->cmdbuff, ccline->cmdlen, ccline->cmdpos, false);
|
set_cmd_context(xp, ccline->cmdbuff, ccline->cmdlen, ccline->cmdpos, false);
|
||||||
} else {
|
} else {
|
||||||
|
may_expand_pattern = options & WILD_MAY_EXPAND_PATTERN;
|
||||||
set_expand_context(xp);
|
set_expand_context(xp);
|
||||||
|
may_expand_pattern = false;
|
||||||
}
|
}
|
||||||
if (xp->xp_context == EXPAND_LUA) {
|
if (xp->xp_context == EXPAND_LUA) {
|
||||||
nlua_expand_pat(xp);
|
nlua_expand_pat(xp);
|
||||||
|
@@ -4505,7 +4505,7 @@ func Test_search_complete()
|
|||||||
call feedkeys("gg/Fo\<tab>\<f9>", 'tx')
|
call feedkeys("gg/Fo\<tab>\<f9>", 'tx')
|
||||||
call assert_equal(['Foobar', 'FooBARR'], g:compl_info.matches)
|
call assert_equal(['Foobar', 'FooBARR'], g:compl_info.matches)
|
||||||
call feedkeys("gg/FO\<tab>\<f9>", 'tx')
|
call feedkeys("gg/FO\<tab>\<f9>", 'tx')
|
||||||
call assert_equal({}, g:compl_info)
|
call assert_equal({}, g:compl_info)
|
||||||
call feedkeys("gg/\\cFo\<tab>\<f9>", 'tx')
|
call feedkeys("gg/\\cFo\<tab>\<f9>", 'tx')
|
||||||
call assert_equal(['\cFoobar', '\cFooBAr', '\cFooBARR'], g:compl_info.matches)
|
call assert_equal(['\cFoobar', '\cFooBAr', '\cFooBARR'], g:compl_info.matches)
|
||||||
|
|
||||||
@@ -4525,7 +4525,12 @@ func Test_search_complete()
|
|||||||
call feedkeys("gg/Fo\<tab>\<f9>", 'tx')
|
call feedkeys("gg/Fo\<tab>\<f9>", 'tx')
|
||||||
call assert_equal(['Foobar', 'FooBARR'], g:compl_info.matches)
|
call assert_equal(['Foobar', 'FooBARR'], g:compl_info.matches)
|
||||||
call feedkeys("gg/FO\<tab>\<f9>", 'tx')
|
call feedkeys("gg/FO\<tab>\<f9>", '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\<tab>\<f9>", 'tx')
|
call feedkeys("gg/foob\<tab>\<f9>", 'tx')
|
||||||
call assert_equal(['foobar', 'foobarr'], g:compl_info.matches)
|
call assert_equal(['foobar', 'foobarr'], g:compl_info.matches)
|
||||||
call feedkeys("gg/\\Cfo\<tab>\<f9>", 'tx')
|
call feedkeys("gg/\\Cfo\<tab>\<f9>", 'tx')
|
||||||
@@ -4630,44 +4635,44 @@ func Test_range_complete()
|
|||||||
|
|
||||||
for trig in ["\<tab>", "\<c-z>"]
|
for trig in ["\<tab>", "\<c-z>"]
|
||||||
call feedkeys($":%s/a{trig}\<f9>", 'xt')
|
call feedkeys($":%s/a{trig}\<f9>", '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}\<f9>", 'xt')
|
" call feedkeys($":vim9cmd :%s/a{trig}\<f9>", 'xt')
|
||||||
call feedkeys($":verbose :%s/a{trig}\<f9>", 'xt')
|
call feedkeys($":verbose :%s/a{trig}\<f9>", 'xt')
|
||||||
call assert_equal(['ab', 'a', 'af'], g:compl_info.matches)
|
call assert_equal(['ab', 'a', 'af'], g:compl_info.matches)
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
call feedkeys(":%s/\<c-z>\<f9>", 'xt')
|
call feedkeys(":%s/\<c-z>\<f9>", 'xt')
|
||||||
call assert_equal({}, g:compl_info)
|
call assert_equal({}, g:compl_info)
|
||||||
|
|
||||||
for cmd in ['s', 'g']
|
for cmd in ['s', 'g']
|
||||||
call feedkeys(":1,2" . cmd . "/a\<c-z>\<f9>", 'xt')
|
call feedkeys($":1,2{cmd}/a\<c-z>\<f9>", 'xt')
|
||||||
call assert_equal(['ab', 'a'], g:compl_info.matches)
|
call assert_equal(['ab', 'a'], g:compl_info.matches)
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
1
|
1
|
||||||
call feedkeys(":.,+2s/a\<c-z>\<f9>", 'xt')
|
call feedkeys(":.,+2s/a\<c-z>\<f9>", 'xt')
|
||||||
call assert_equal(['ab', 'a'], g:compl_info.matches)
|
call assert_equal(['ab', 'a'], g:compl_info.matches)
|
||||||
|
|
||||||
/f
|
/f
|
||||||
call feedkeys(":1,s/b\<c-z>\<f9>", 'xt')
|
call feedkeys(":1,s/b\<c-z>\<f9>", 'xt')
|
||||||
call assert_equal(['b', 'ba'], g:compl_info.matches)
|
call assert_equal(['b', 'ba'], g:compl_info.matches)
|
||||||
|
|
||||||
/c
|
/c
|
||||||
call feedkeys(":\\?,4s/a\<c-z>\<f9>", 'xt')
|
call feedkeys(":\\?,4s/a\<c-z>\<f9>", 'xt')
|
||||||
call assert_equal(['a', 'af'], g:compl_info.matches)
|
call assert_equal(['a', 'af'], g:compl_info.matches)
|
||||||
|
|
||||||
%s/c/c/
|
%s/c/c/
|
||||||
call feedkeys(":1,\\&s/a\<c-z>\<f9>", 'xt')
|
call feedkeys(":1,\\&s/a\<c-z>\<f9>", 'xt')
|
||||||
call assert_equal(['ab', 'a'], g:compl_info.matches)
|
call assert_equal(['ab', 'a'], g:compl_info.matches)
|
||||||
|
|
||||||
3
|
3
|
||||||
normal! ma
|
normal! ma
|
||||||
call feedkeys(":'a,$s/a\<c-z>\<f9>", 'xt')
|
call feedkeys(":'a,$s/a\<c-z>\<f9>", '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])
|
" Line number followed by a search pattern ([start]/pattern/[command])
|
||||||
call feedkeys("3/a\<c-z>\<f9>", 'xt')
|
call feedkeys("3/a\<c-z>\<f9>", 'xt')
|
||||||
call assert_equal(['a', 'af', 'ab'], g:compl_info.matches)
|
call assert_equal(['a', 'af', 'ab'], g:compl_info.matches)
|
||||||
|
|
||||||
bw!
|
bw!
|
||||||
call Ntest_override("char_avail", 0)
|
call Ntest_override("char_avail", 0)
|
||||||
|
Reference in New Issue
Block a user