forked from aniani/vim
patch 9.1.0774: "shellcmdline" doesn't work with getcompletion()
Problem: "shellcmdline" doesn't work with getcompletion(). Solution: Use set_context_for_wildcard_arg() (zeertzjq). closes: #15834 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
e58e9015cc
commit
85f36d61e0
@@ -1,4 +1,4 @@
|
|||||||
*builtin.txt* For Vim version 9.1. Last change: 2024 Oct 08
|
*builtin.txt* For Vim version 9.1. Last change: 2024 Oct 09
|
||||||
|
|
||||||
|
|
||||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||||
@@ -4091,7 +4091,7 @@ getcompletion({pat}, {type} [, {filtered}]) *getcompletion()*
|
|||||||
cscope |:cscope| suboptions
|
cscope |:cscope| suboptions
|
||||||
custom,{func} custom completion, defined via {func}
|
custom,{func} custom completion, defined via {func}
|
||||||
customlist,{func} custom completion, defined via {func}
|
customlist,{func} custom completion, defined via {func}
|
||||||
diff_buffer |:diffget| and |:diffput| completion
|
diff_buffer |:diffget| and |:diffput| completion
|
||||||
dir directory names
|
dir directory names
|
||||||
dir_in_path directory names in |'cdpath'|
|
dir_in_path directory names in |'cdpath'|
|
||||||
environment environment variable names
|
environment environment variable names
|
||||||
@@ -4115,6 +4115,7 @@ getcompletion({pat}, {type} [, {filtered}]) *getcompletion()*
|
|||||||
runtime |:runtime| completion
|
runtime |:runtime| completion
|
||||||
scriptnames sourced script names |:scriptnames|
|
scriptnames sourced script names |:scriptnames|
|
||||||
shellcmd Shell command
|
shellcmd Shell command
|
||||||
|
shellcmdline Shell command line with filename arguments
|
||||||
sign |:sign| suboptions
|
sign |:sign| suboptions
|
||||||
syntax syntax file names |'syntax'|
|
syntax syntax file names |'syntax'|
|
||||||
syntime |:syntime| suboptions
|
syntime |:syntime| suboptions
|
||||||
|
@@ -1721,7 +1721,7 @@ set_context_for_wildcard_arg(
|
|||||||
// characters that end the command and white space.
|
// characters that end the command and white space.
|
||||||
else if (c == '|' || c == '\n' || c == '"' || (VIM_ISWHITE(c)
|
else if (c == '|' || c == '\n' || c == '"' || (VIM_ISWHITE(c)
|
||||||
#ifdef SPACE_IN_FILENAME
|
#ifdef SPACE_IN_FILENAME
|
||||||
&& (!(eap->argt & EX_NOSPC) || usefilter)
|
&& (!(eap != NULL && (eap->argt & EX_NOSPC)) || usefilter)
|
||||||
#endif
|
#endif
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@@ -1756,7 +1756,10 @@ set_context_for_wildcard_arg(
|
|||||||
xp->xp_context = EXPAND_FILES;
|
xp->xp_context = EXPAND_FILES;
|
||||||
|
|
||||||
// For a shell command more chars need to be escaped.
|
// For a shell command more chars need to be escaped.
|
||||||
if (usefilter || eap->cmdidx == CMD_bang || eap->cmdidx == CMD_terminal || *complp == EXPAND_SHELLCMDLINE)
|
if (usefilter
|
||||||
|
|| (eap != NULL
|
||||||
|
&& (eap->cmdidx == CMD_bang || eap->cmdidx == CMD_terminal))
|
||||||
|
|| *complp == EXPAND_SHELLCMDLINE)
|
||||||
{
|
{
|
||||||
#ifndef BACKSLASH_IN_FILENAME
|
#ifndef BACKSLASH_IN_FILENAME
|
||||||
xp->xp_shell = TRUE;
|
xp->xp_shell = TRUE;
|
||||||
@@ -4208,6 +4211,13 @@ f_getcompletion(typval_T *argvars, typval_T *rettv)
|
|||||||
set_context_in_runtime_cmd(&xpc, xpc.xp_pattern);
|
set_context_in_runtime_cmd(&xpc, xpc.xp_pattern);
|
||||||
xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern);
|
xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern);
|
||||||
}
|
}
|
||||||
|
if (xpc.xp_context == EXPAND_SHELLCMDLINE)
|
||||||
|
{
|
||||||
|
int context = EXPAND_SHELLCMDLINE;
|
||||||
|
set_context_for_wildcard_arg(NULL, xpc.xp_pattern, FALSE, &xpc,
|
||||||
|
&context);
|
||||||
|
xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmdline_fuzzy_completion_supported(&xpc))
|
if (cmdline_fuzzy_completion_supported(&xpc))
|
||||||
|
@@ -1084,6 +1084,8 @@ func Test_cmdline_complete_shellcmdline()
|
|||||||
|
|
||||||
call feedkeys(":MyCmd whoam\<C-A>\<C-B>\"\<CR>", 'tx')
|
call feedkeys(":MyCmd whoam\<C-A>\<C-B>\"\<CR>", 'tx')
|
||||||
call assert_match('^".*\<whoami\>', @:)
|
call assert_match('^".*\<whoami\>', @:)
|
||||||
|
let l = getcompletion('whoam', 'shellcmdline')
|
||||||
|
call assert_match('\<whoami\>', join(l, ' '))
|
||||||
|
|
||||||
delcommand MyCmd
|
delcommand MyCmd
|
||||||
endfunc
|
endfunc
|
||||||
@@ -3649,9 +3651,13 @@ func Test_cmdline_complete_shellcmdline_argument()
|
|||||||
|
|
||||||
call feedkeys(":MyCmd vim test_cmdline.\<Tab>\<C-B>\"\<CR>", 'xt')
|
call feedkeys(":MyCmd vim test_cmdline.\<Tab>\<C-B>\"\<CR>", 'xt')
|
||||||
call assert_equal('"MyCmd vim test_cmdline.vim', @:)
|
call assert_equal('"MyCmd vim test_cmdline.vim', @:)
|
||||||
|
call assert_equal(['test_cmdline.vim'],
|
||||||
|
\ getcompletion('vim test_cmdline.', 'shellcmdline'))
|
||||||
|
|
||||||
call feedkeys(":MyCmd vim nonexistentfile\<Tab>\<C-B>\"\<CR>", 'xt')
|
call feedkeys(":MyCmd vim nonexistentfile\<Tab>\<C-B>\"\<CR>", 'xt')
|
||||||
call assert_equal('"MyCmd vim nonexistentfile', @:)
|
call assert_equal('"MyCmd vim nonexistentfile', @:)
|
||||||
|
call assert_equal([],
|
||||||
|
\ getcompletion('vim nonexistentfile', 'shellcmdline'))
|
||||||
|
|
||||||
let compl1 = getcompletion('', 'file')[0]
|
let compl1 = getcompletion('', 'file')[0]
|
||||||
let compl2 = getcompletion('', 'file')[1]
|
let compl2 = getcompletion('', 'file')[1]
|
||||||
@@ -3668,9 +3674,13 @@ func Test_cmdline_complete_shellcmdline_argument()
|
|||||||
set wildoptions&
|
set wildoptions&
|
||||||
call feedkeys(":MyCmd vim test_cmdline.\<Tab>\<C-B>\"\<CR>", 'xt')
|
call feedkeys(":MyCmd vim test_cmdline.\<Tab>\<C-B>\"\<CR>", 'xt')
|
||||||
call assert_equal('"MyCmd vim test_cmdline.vim', @:)
|
call assert_equal('"MyCmd vim test_cmdline.vim', @:)
|
||||||
|
call assert_equal(['test_cmdline.vim'],
|
||||||
|
\ getcompletion('vim test_cmdline.', 'shellcmdline'))
|
||||||
|
|
||||||
call feedkeys(":MyCmd vim nonexistentfile\<Tab>\<C-B>\"\<CR>", 'xt')
|
call feedkeys(":MyCmd vim nonexistentfile\<Tab>\<C-B>\"\<CR>", 'xt')
|
||||||
call assert_equal('"MyCmd vim nonexistentfile', @:)
|
call assert_equal('"MyCmd vim nonexistentfile', @:)
|
||||||
|
call assert_equal([],
|
||||||
|
\ getcompletion('vim nonexistentfile', 'shellcmdline'))
|
||||||
|
|
||||||
let compl1 = getcompletion('', 'file')[0]
|
let compl1 = getcompletion('', 'file')[0]
|
||||||
let compl2 = getcompletion('', 'file')[1]
|
let compl2 = getcompletion('', 'file')[1]
|
||||||
|
@@ -704,6 +704,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
774,
|
||||||
/**/
|
/**/
|
||||||
773,
|
773,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user