]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0770: current command line completion is a bit limited v9.1.0770
authorRuslan Russkikh <dvrussk@yandex.ru>
Tue, 8 Oct 2024 20:21:05 +0000 (22:21 +0200)
committerChristian Brabandt <cb@256bit.org>
Tue, 8 Oct 2024 20:24:04 +0000 (22:24 +0200)
Problem:  current command completion is a bit limited
Solution: Add the shellcmdline completion type and getmdcomplpat()
          function (Ruslan Russkikh).

closes: #15823

Signed-off-by: Ruslan Russkikh <dvrussk@yandex.ru>
Signed-off-by: Christian Brabandt <cb@256bit.org>
14 files changed:
runtime/doc/builtin.txt
runtime/doc/map.txt
runtime/doc/tags
runtime/doc/usr_41.txt
runtime/doc/version9.txt
runtime/syntax/vim.vim
src/cmdexpand.c
src/evalfunc.c
src/ex_getln.c
src/proto/ex_getln.pro
src/testdir/test_cmdline.vim
src/usercmd.c
src/version.c
src/vim.h

index fe0b9aa335a215aac154cfdb9a3012157394a3e0..880dfcd78506432301025ceb9a46167d35c0d500 100644 (file)
@@ -1,4 +1,4 @@
-*builtin.txt*  For Vim version 9.1.  Last change: 2024 Sep 23
+*builtin.txt*  For Vim version 9.1.  Last change: 2024 Oct 08
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -230,6 +230,8 @@ getcharmod()                        Number  modifiers for the last typed character
 getcharpos({expr})             List    position of cursor, mark, etc.
 getcharsearch()                        Dict    last character search
 getcharstr([{expr}])           String  get one character from the user
+getcmdcomplpat()               String  return the completion pattern of the
+                                       current command-line completion
 getcmdcompltype()              String  return the type of the current
                                        command-line completion
 getcmdline()                   String  return the current command-line input
@@ -3973,6 +3975,16 @@ getcharstr([{expr}])                                     *getcharstr()*
 
                Return type: |String|
 
+getcmdcomplpat()                                       *getcmdcomplpat()*
+               Return completion pattern of the current command-line.
+               Only works when the command line is being edited, thus
+               requires use of |c_CTRL-\_e| or |c_CTRL-R_=|.
+               Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()|,
+               |getcmdprompt()|, |getcmdcompltype()| and |setcmdline()|.
+               Returns an empty string when completion is not defined.
+
+               Return type: |String|
+
 
 getcmdcompltype()                                      *getcmdcompltype()*
                Return the type of the current command-line completion.
@@ -3980,7 +3992,7 @@ getcmdcompltype()                                 *getcmdcompltype()*
                requires use of |c_CTRL-\_e| or |c_CTRL-R_=|.
                See |:command-completion| for the return string.
                Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()|,
-               |getcmdprompt()| and |setcmdline()|.
+               |getcmdprompt()|, |getcmdcomplpat()| and |setcmdline()|.
                Returns an empty string when completion is not defined.
 
                Return type: |String|
index 2773140c5d49fb24ae375e87d16ffdd0e0310c75..899b24bac14671414bb2b6591aee24e41f66ed31 100644 (file)
@@ -1,4 +1,4 @@
-*map.txt*       For Vim version 9.1.  Last change: 2024 Oct 07
+*map.txt*       For Vim version 9.1.  Last change: 2024 Oct 08
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -1657,6 +1657,8 @@ completion can be enabled:
        -complete=runtime       file and directory names in |'runtimepath'|
        -complete=scriptnames   sourced script names
        -complete=shellcmd      Shell command
+       -complete=shellcmdline  First is a shell command and subsequent ones
+                               are filenames. The same behavior as |:!cmd|
        -complete=sign          |:sign| suboptions
        -complete=syntax        syntax file names |'syntax'|
        -complete=syntime       |:syntime| suboptions
index 42c7c649ec781cf6bd8ba3da29ac0b7a7a220c50..246ea96ce44f19da94aeb8ce943429dcad306270 100644 (file)
@@ -7827,6 +7827,7 @@ getcharmod()      builtin.txt     /*getcharmod()*
 getcharpos()   builtin.txt     /*getcharpos()*
 getcharsearch()        builtin.txt     /*getcharsearch()*
 getcharstr()   builtin.txt     /*getcharstr()*
+getcmdcomplpat()       builtin.txt     /*getcmdcomplpat()*
 getcmdcompltype()      builtin.txt     /*getcmdcompltype()*
 getcmdline()   builtin.txt     /*getcmdline()*
 getcmdpos()    builtin.txt     /*getcmdpos()*
index 123dcbb68c1a76c4d0d42d49be8e08a79e4e6ae1..af67429eceb4c9836420d9c0f002984b621cac1b 100644 (file)
@@ -1068,6 +1068,8 @@ Buffers, windows and the argument list:
        swapname()              get the swap file path of a buffer
 
 Command line:                                  *command-line-functions*
+       getcmdcomplpat()        get completion pattern of the current command
+                               line
        getcmdcompltype()       get the type of the current command line
                                completion
        getcmdline()            get the current command line input
index 56bb7e21d15ee19c5c06db4dab0c6ac4b1b07683..a9434335c6d174ea2ee491ac272e2ce0ace3ddda 100644 (file)
@@ -1,4 +1,4 @@
-*version9.txt*  For Vim version 9.1.  Last change: 2024 Oct 05
+*version9.txt*  For Vim version 9.1.  Last change: 2024 Oct 08
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -41589,6 +41589,8 @@ Changed~
 - allow to complete directories from 'cdpath' for |:cd| and similar commands,
   add the "cd_in_path" completion type for e.g. |:command-complete| and
   |getcompletion()|
+- allow to complete shell commands and files using the new shellcmdline
+  completion type using |:command-complete| and |getcmdcomplpat()|
 - add 'cpoptions' flag "z" |cpo-z|, to disable some (traditional) vi
   behaviour/inconsistency (see |d-special| and |cw|).
 - allow to specify additional attributes in the completion menu (allows to
@@ -41608,6 +41610,7 @@ Functions: ~
 |diff()|               diff two Lists of strings
 |filecopy()|           copy a file {from} to {to}
 |foreach()|            apply function to List items
+|getcmdcomplpat()|     Shell command line completion
 |getcmdprompt()|       get prompt for input()/confirm()
 |getregion()|          get a region of text from a buffer
 |getregionpos()|       get a list of positions for a region
index 2598cae56fdb9c9848c28aa87dac6bef083a9100..28fdda5215c5c26329f93bd962d671171a4dfbbd 100644 (file)
@@ -2,7 +2,7 @@
 " Language:       Vim script
 " Maintainer:     Hirohito Higashi <h.east.727 ATMARK gmail.com>
 "         Doug Kearns <dougkearns@gmail.com>
-" Last Change:    2024 Oct 05
+" Last Change:    2024 Oct 08
 " Former Maintainer: Charles E. Campbell
 
 " DO NOT CHANGE DIRECTLY.
@@ -103,11 +103,11 @@ syn case match
 " GEN_SYN_VIM: vimFuncName, START_STR='syn keyword vimFuncName contained', END_STR=''
 syn keyword vimFuncName contained abs acos add and append appendbufline argc argidx arglistid argv asin assert_beeps assert_equal assert_equalfile assert_exception assert_fails assert_false assert_inrange assert_match assert_nobeep assert_notequal assert_notmatch assert_report assert_true atan atan2 autocmd_add autocmd_delete autocmd_get balloon_gettext balloon_show balloon_split bindtextdomain blob2list browse browsedir bufadd bufexists buflisted bufload bufloaded bufname bufnr bufwinid bufwinnr byte2line byteidx byteidxcomp call ceil ch_canread ch_close ch_close_in ch_evalexpr ch_evalraw ch_getbufnr ch_getjob ch_info ch_log ch_logfile ch_open ch_read ch_readblob ch_readraw ch_sendexpr ch_sendraw ch_setoptions ch_status changenr char2nr charclass charcol charidx
 syn keyword vimFuncName contained chdir cindent clearmatches col complete complete_add complete_check complete_info confirm copy cos cosh count cscope_connection cursor debugbreak deepcopy delete deletebufline did_filetype diff diff_filler diff_hlID digraph_get digraph_getlist digraph_set digraph_setlist echoraw empty environ err_teapot escape eval eventhandler executable execute exepath exists exists_compiled exp expand expandcmd extend extendnew feedkeys filecopy filereadable filewritable filter finddir findfile flatten flattennew float2nr floor fmod fnameescape fnamemodify foldclosed foldclosedend foldlevel foldtext foldtextresult foreach foreground fullcommand funcref function garbagecollect get getbufinfo getbufline getbufoneline getbufvar getcellwidths getchangelist
-syn keyword vimFuncName contained getchar getcharmod getcharpos getcharsearch getcharstr getcmdcompltype getcmdline getcmdpos getcmdprompt getcmdscreenpos getcmdtype getcmdwintype getcompletion getcurpos getcursorcharpos getcwd getenv getfontname getfperm getfsize getftime getftype getimstatus getjumplist getline getloclist getmarklist getmatches getmousepos getmouseshape getpid getpos getqflist getreg getreginfo getregion getregionpos getregtype getscriptinfo gettabinfo gettabvar gettabwinvar gettagstack gettext getwininfo getwinpos getwinposx getwinposy getwinvar glob glob2regpat globpath has has_key haslocaldir hasmapto histadd histdel histget histnr hlID hlexists hlget hlset hostname iconv id indent index indexof input inputdialog inputlist inputrestore inputsave
-syn keyword vimFuncName contained inputsecret insert instanceof interrupt invert isabsolutepath isdirectory isinf islocked isnan items job_getchannel job_info job_setoptions job_start job_status job_stop join js_decode js_encode json_decode json_encode keys keytrans len libcall libcallnr line line2byte lispindent list2blob list2str listener_add listener_flush listener_remove localtime log log10 luaeval map maparg mapcheck maplist mapnew mapset match matchadd matchaddpos matcharg matchbufline matchdelete matchend matchfuzzy matchfuzzypos matchlist matchstr matchstrlist matchstrpos max menu_info min mkdir mode mzeval nextnonblank nr2char or pathshorten perleval popup_atcursor popup_beval popup_clear popup_close popup_create popup_dialog popup_filter_menu popup_filter_yesno
-syn keyword vimFuncName contained popup_findecho popup_findinfo popup_findpreview popup_getoptions popup_getpos popup_hide popup_list popup_locate popup_menu popup_move popup_notification popup_setbuf popup_setoptions popup_settext popup_show pow prevnonblank printf prompt_getprompt prompt_setcallback prompt_setinterrupt prompt_setprompt prop_add prop_add_list prop_clear prop_find prop_list prop_remove prop_type_add prop_type_change prop_type_delete prop_type_get prop_type_list pum_getpos pumvisible py3eval pyeval pyxeval rand range readblob readdir readdirex readfile reduce reg_executing reg_recording reltime reltimefloat reltimestr remote_expr remote_foreground remote_peek remote_read remote_send remote_startserver remove rename repeat resolve reverse round
-syn keyword vimFuncName contained rubyeval screenattr screenchar screenchars screencol screenpos screenrow screenstring search searchcount searchdecl searchpair searchpairpos searchpos server2client serverlist setbufline setbufvar setcellwidths setcharpos setcharsearch setcmdline setcmdpos setcursorcharpos setenv setfperm setline setloclist setmatches setpos setqflist setreg settabvar settabwinvar settagstack setwinvar sha256 shellescape shiftwidth sign_define sign_getdefined sign_getplaced sign_jump sign_place sign_placelist sign_undefine sign_unplace sign_unplacelist simplify sin sinh slice sort sound_clear sound_playevent sound_playfile sound_stop soundfold spellbadword spellsuggest split sqrt srand state str2float str2list str2nr strcharlen strcharpart strchars
-syn keyword vimFuncName contained strdisplaywidth strftime strgetchar stridx string strlen strpart strptime strridx strtrans strutf16len strwidth submatch substitute swapfilelist swapinfo swapname synID synIDattr synIDtrans synconcealed synstack system systemlist tabpagebuflist tabpagenr tabpagewinnr tagfiles taglist tan tanh tempname term_dumpdiff term_dumpload term_dumpwrite term_getaltscreen term_getansicolors term_getattr term_getcursor term_getjob term_getline term_getscrolled term_getsize term_getstatus term_gettitle term_gettty term_list term_scrape term_sendkeys term_setansicolors term_setapi term_setkill term_setrestore term_setsize term_start term_wait terminalprops test_alloc_fail test_autochdir test_feedinput test_garbagecollect_now test_garbagecollect_soon
+syn keyword vimFuncName contained getchar getcharmod getcharpos getcharsearch getcharstr getcmdcomplpat getcmdcompltype getcmdline getcmdpos getcmdprompt getcmdscreenpos getcmdtype getcmdwintype getcompletion getcurpos getcursorcharpos getcwd getenv getfontname getfperm getfsize getftime getftype getimstatus getjumplist getline getloclist getmarklist getmatches getmousepos getmouseshape getpid getpos getqflist getreg getreginfo getregion getregionpos getregtype getscriptinfo gettabinfo gettabvar gettabwinvar gettagstack gettext getwininfo getwinpos getwinposx getwinposy getwinvar glob glob2regpat globpath has has_key haslocaldir hasmapto histadd histdel histget histnr hlID hlexists hlget hlset hostname iconv id indent index indexof input inputdialog inputlist
+syn keyword vimFuncName contained inputrestore inputsave inputsecret insert instanceof interrupt invert isabsolutepath isdirectory isinf islocked isnan items job_getchannel job_info job_setoptions job_start job_status job_stop join js_decode js_encode json_decode json_encode keys keytrans len libcall libcallnr line line2byte lispindent list2blob list2str listener_add listener_flush listener_remove localtime log log10 luaeval map maparg mapcheck maplist mapnew mapset match matchadd matchaddpos matcharg matchbufline matchdelete matchend matchfuzzy matchfuzzypos matchlist matchstr matchstrlist matchstrpos max menu_info min mkdir mode mzeval nextnonblank nr2char or pathshorten perleval popup_atcursor popup_beval popup_clear popup_close popup_create popup_dialog popup_filter_menu
+syn keyword vimFuncName contained popup_filter_yesno popup_findecho popup_findinfo popup_findpreview popup_getoptions popup_getpos popup_hide popup_list popup_locate popup_menu popup_move popup_notification popup_setbuf popup_setoptions popup_settext popup_show pow prevnonblank printf prompt_getprompt prompt_setcallback prompt_setinterrupt prompt_setprompt prop_add prop_add_list prop_clear prop_find prop_list prop_remove prop_type_add prop_type_change prop_type_delete prop_type_get prop_type_list pum_getpos pumvisible py3eval pyeval pyxeval rand range readblob readdir readdirex readfile reduce reg_executing reg_recording reltime reltimefloat reltimestr remote_expr remote_foreground remote_peek remote_read remote_send remote_startserver remove rename repeat resolve
+syn keyword vimFuncName contained reverse round rubyeval screenattr screenchar screenchars screencol screenpos screenrow screenstring search searchcount searchdecl searchpair searchpairpos searchpos server2client serverlist setbufline setbufvar setcellwidths setcharpos setcharsearch setcmdline setcmdpos setcursorcharpos setenv setfperm setline setloclist setmatches setpos setqflist setreg settabvar settabwinvar settagstack setwinvar sha256 shellescape shiftwidth sign_define sign_getdefined sign_getplaced sign_jump sign_place sign_placelist sign_undefine sign_unplace sign_unplacelist simplify sin sinh slice sort sound_clear sound_playevent sound_playfile sound_stop soundfold spellbadword spellsuggest split sqrt srand state str2float str2list str2nr strcharlen strcharpart
+syn keyword vimFuncName contained strchars strdisplaywidth strftime strgetchar stridx string strlen strpart strptime strridx strtrans strutf16len strwidth submatch substitute swapfilelist swapinfo swapname synID synIDattr synIDtrans synconcealed synstack system systemlist tabpagebuflist tabpagenr tabpagewinnr tagfiles taglist tan tanh tempname term_dumpdiff term_dumpload term_dumpwrite term_getaltscreen term_getansicolors term_getattr term_getcursor term_getjob term_getline term_getscrolled term_getsize term_getstatus term_gettitle term_gettty term_list term_scrape term_sendkeys term_setansicolors term_setapi term_setkill term_setrestore term_setsize term_start term_wait terminalprops test_alloc_fail test_autochdir test_feedinput test_garbagecollect_now test_garbagecollect_soon
 syn keyword vimFuncName contained test_getvalue test_gui_event test_ignore_error test_mswin_event test_null_blob test_null_channel test_null_dict test_null_function test_null_job test_null_list test_null_partial test_null_string test_option_not_set test_override test_refcount test_setmouse test_settime test_srand_seed test_unknown test_void timer_info timer_pause timer_start timer_stop timer_stopall tolower toupper tr trim trunc type typename undofile undotree uniq utf16idx values virtcol virtcol2col visualmode wildmenumode win_execute win_findbuf win_getid win_gettype win_gotoid win_id2tabwin win_id2win win_move_separator win_move_statusline win_screenpos win_splitmove winbufnr wincol windowsversion winheight winlayout winline winnr winrestcmd winrestview winsaveview
 syn keyword vimFuncName contained winwidth wordcount writefile xor
 
@@ -542,7 +542,7 @@ endif
 syn case ignore
 syn keyword    vimUserCmdAttrKey   contained   a[ddr] ban[g] bar bu[ffer] com[plete] cou[nt] k[eepscript] n[args] ra[nge] re[gister]
 " GEN_SYN_VIM: vimUserCmdAttrCmplt, START_STR='syn keyword vimUserCmdAttrCmplt contained', END_STR=''
-syn keyword vimUserCmdAttrCmplt contained arglist augroup behave breakpoint buffer color command compiler cscope diff_buffer dir dir_in_path environment event expression file file_in_path filetype function help highlight history keymap locale mapclear mapping menu messages option packadd runtime scriptnames shellcmd sign syntax syntime tag tag_listfiles user var
+syn keyword vimUserCmdAttrCmplt contained arglist augroup behave breakpoint buffer color command compiler cscope diff_buffer dir dir_in_path environment event expression file file_in_path filetype function help highlight history keymap locale mapclear mapping menu messages option packadd runtime scriptnames shellcmd shellcmdline sign syntax syntime tag tag_listfiles user var
 syn keyword    vimUserCmdAttrCmplt     contained       custom customlist nextgroup=vimUserCmdAttrCmpltFunc,vimUserCmdError
 syn match      vimUserCmdAttrCmpltFunc contained       ",\%([sS]:\|<[sS][iI][dD]>\)\=\%(\h\w*\%([.#]\h\w*\)\+\|\h\w*\)"hs=s+1 nextgroup=vimUserCmdError
 " GEN_SYN_VIM: vimUserCmdAttrAddr, START_STR='syn keyword vimUserCmdAttrAddr contained', END_STR=''
index c1ed03b78c622163aeb354ef4eb16b10810184da..c7c42abffa82b6d955419010691af7f799695147 100644 (file)
@@ -59,6 +59,7 @@ cmdline_fuzzy_completion_supported(expand_T *xp)
            && xp->xp_context != EXPAND_PACKADD
            && xp->xp_context != EXPAND_RUNTIME
            && xp->xp_context != EXPAND_SHELLCMD
+           && xp->xp_context != EXPAND_SHELLCMDLINE
            && xp->xp_context != EXPAND_TAGS
            && xp->xp_context != EXPAND_TAGS_LISTFILES
            && xp->xp_context != EXPAND_USER_LIST);
@@ -1754,7 +1755,7 @@ set_context_for_wildcard_arg(
     xp->xp_context = EXPAND_FILES;
 
     // For a shell command more chars need to be escaped.
-    if (usefilter || eap->cmdidx == CMD_bang || eap->cmdidx == CMD_terminal)
+    if (usefilter || eap->cmdidx == CMD_bang || eap->cmdidx == CMD_terminal || *complp == EXPAND_SHELLCMDLINE)
     {
 #ifndef BACKSLASH_IN_FILENAME
        xp->xp_shell = TRUE;
index 67104eaf2c7caa7c453e6930723683b0000725b1..d902045e886fdec146f7682014eeda55c1ba6205 100644 (file)
@@ -2091,6 +2091,8 @@ static funcentry_T global_functions[] =
                        ret_dict_any,       f_getcharsearch},
     {"getcharstr",     0, 1, 0,            arg1_bool,
                        ret_string,         f_getcharstr},
+    {"getcmdcomplpat", 0, 0, 0,            NULL,
+                       ret_string,         f_getcmdcomplpat},
     {"getcmdcompltype",        0, 0, 0,            NULL,
                        ret_string,         f_getcmdcompltype},
     {"getcmdline",     0, 0, 0,            NULL,
index 980faf8566344b1272fb0c9cbc26afecdc6ff2e3..b7804d111ecc53785136713e3ffe6786ec64f65c 100644 (file)
@@ -4204,6 +4204,40 @@ get_cmdline_str(void)
     return vim_strnsave(p->cmdbuff, p->cmdlen);
 }
 
+/*
+ * Get the current command-line completion pattern.
+ */
+    static char_u *
+get_cmdline_completion_pattern(void)
+{
+    cmdline_info_T *p;
+    int                xp_context;
+
+    if (cmdline_star > 0)
+       return NULL;
+
+    p = get_ccline_ptr();
+    if (p == NULL || p->xpc == NULL)
+       return NULL;
+
+    xp_context = p->xpc->xp_context;
+    if (xp_context == EXPAND_NOTHING)
+    {
+       set_expand_context(p->xpc);
+       xp_context = p->xpc->xp_context;
+       p->xpc->xp_context = EXPAND_NOTHING;
+    }
+    if (xp_context == EXPAND_UNSUCCESSFUL)
+       return NULL;
+
+    char_u *compl_pat = p->xpc->xp_pattern;
+
+    if (compl_pat == NULL)
+       return NULL;
+
+    return vim_strsave(compl_pat);
+}
+
 /*
  * Get the current command-line completion type.
  */
@@ -4247,6 +4281,16 @@ get_cmdline_completion(void)
     return vim_strsave(cmd_compl);
 }
 
+/*
+ * "getcmdcomplpat()" function
+ */
+    void
+f_getcmdcomplpat(typval_T *argvars UNUSED, typval_T *rettv)
+{
+    rettv->v_type = VAR_STRING;
+    rettv->vval.v_string = get_cmdline_completion_pattern();
+}
+
 /*
  * "getcmdcompltype()" function
  */
index 1ab3b1ccafc04d350240942f671c467a97db4bc2..cc8723ad7d135ae96596978a05bbf456da90ba27 100644 (file)
@@ -30,6 +30,7 @@ char_u *vim_strsave_fnameescape(char_u *fname, int what);
 void escape_fname(char_u **pp);
 void tilde_replace(char_u *orig_pat, int num_files, char_u **files);
 cmdline_info_T *get_cmdline_info(void);
+void f_getcmdcomplpat(typval_T *argvars, typval_T *rettv);
 void f_getcmdcompltype(typval_T *argvars, typval_T *rettv);
 void f_getcmdline(typval_T *argvars, typval_T *rettv);
 void f_getcmdpos(typval_T *argvars, typval_T *rettv);
index 790efaadd045e98d8245976ba7be42c6f6313562..418dafadcf23a258bc57da0c774b3825459ea01b 100644 (file)
@@ -1078,6 +1078,16 @@ func Test_cmdline_complete_user_names()
   endif
 endfunc
 
+func Test_cmdline_complete_shellcmdline()
+  CheckExecutable whoami
+  command -nargs=1 -complete=shellcmdline MyCmd
+
+  call feedkeys(":MyCmd whoam\<C-A>\<C-B>\"\<CR>", 'tx')
+  call assert_match('^".*\<whoami\>', @:)
+
+  delcommand MyCmd
+endfunc
+
 func Test_cmdline_complete_bang()
   CheckExecutable whoami
   call feedkeys(":!whoam\<C-A>\<C-B>\"\<CR>", 'tx')
@@ -3631,6 +3641,52 @@ func Test_cmdline_complete_substitute_short()
   endfor
 endfunc
 
+" Test for shellcmdline command argument completion
+func Test_cmdline_complete_shellcmdline_argument()
+  command -nargs=+ -complete=shellcmdline MyCmd
+
+  set wildoptions=fuzzy
+
+  call feedkeys(":MyCmd vim test_cmdline.\<Tab>\<C-B>\"\<CR>", 'xt')
+  call assert_equal('"MyCmd vim test_cmdline.vim', @:)
+
+  call feedkeys(":MyCmd vim nonexistentfile\<Tab>\<C-B>\"\<CR>", 'xt')
+  call assert_equal('"MyCmd vim nonexistentfile', @:)
+
+  let compl1 = getcompletion('', 'file')[0]
+  let compl2 = getcompletion('', 'file')[1]
+  call feedkeys(":MyCmd vim \<Tab>\<C-B>\"\<CR>", 'xt')
+  call assert_equal('"MyCmd vim ' .. compl1, @:)
+
+  call feedkeys(":MyCmd vim \<Tab> \<Tab>\<C-B>\"\<CR>", 'xt')
+  call assert_equal('"MyCmd vim ' .. compl1 .. ' ' .. compl1, @:)
+
+  let compl = getcompletion('', 'file')[1]
+  call feedkeys(":MyCmd vim \<Tab> \<Tab>\<Tab>\<C-B>\"\<CR>", 'xt')
+  call assert_equal('"MyCmd vim ' .. compl1 .. ' ' .. compl2, @:)
+
+  set wildoptions&
+  call feedkeys(":MyCmd vim test_cmdline.\<Tab>\<C-B>\"\<CR>", 'xt')
+  call assert_equal('"MyCmd vim test_cmdline.vim', @:)
+
+  call feedkeys(":MyCmd vim nonexistentfile\<Tab>\<C-B>\"\<CR>", 'xt')
+  call assert_equal('"MyCmd vim nonexistentfile', @:)
+
+  let compl1 = getcompletion('', 'file')[0]
+  let compl2 = getcompletion('', 'file')[1]
+  call feedkeys(":MyCmd vim \<Tab>\<C-B>\"\<CR>", 'xt')
+  call assert_equal('"MyCmd vim ' .. compl1, @:)
+
+  call feedkeys(":MyCmd vim \<Tab> \<Tab>\<C-B>\"\<CR>", 'xt')
+  call assert_equal('"MyCmd vim ' .. compl1 .. ' ' .. compl1, @:)
+
+  let compl = getcompletion('', 'file')[1]
+  call feedkeys(":MyCmd vim \<Tab> \<Tab>\<Tab>\<C-B>\"\<CR>", 'xt')
+  call assert_equal('"MyCmd vim ' .. compl1 .. ' ' .. compl2, @:)
+
+  delcommand MyCmd
+endfunc
+
 " Test for :! shell command argument completion
 func Test_cmdline_complete_bang_cmd_argument()
   set wildoptions=fuzzy
@@ -3642,30 +3698,32 @@ func Test_cmdline_complete_bang_cmd_argument()
 endfunc
 
 func Call_cmd_funcs()
-  return [getcmdpos(), getcmdscreenpos(), getcmdcompltype()]
+  return [getcmdpos(), getcmdscreenpos(), getcmdcompltype(), getcmdcomplpat()]
 endfunc
 
 func Test_screenpos_and_completion()
   call assert_equal(0, getcmdpos())
   call assert_equal(0, getcmdscreenpos())
   call assert_equal('', getcmdcompltype())
+  call assert_equal('', getcmdcomplpat())
 
   cnoremap <expr> <F2> string(Call_cmd_funcs())
   call feedkeys(":let a\<F2>\<C-B>\"\<CR>", "xt")
-  call assert_equal("\"let a[6, 7, 'var']", @:)
+  call assert_equal("\"let a[6, 7, 'var', 'a']", @:)
   call feedkeys(":quit \<F2>\<C-B>\"\<CR>", "xt")
-  call assert_equal("\"quit [6, 7, '']", @:)
+  call assert_equal("\"quit [6, 7, '', '']", @:)
   call feedkeys(":nosuchcommand \<F2>\<C-B>\"\<CR>", "xt")
-  call assert_equal("\"nosuchcommand [15, 16, '']", @:)
+  call assert_equal("\"nosuchcommand [15, 16, '', '']", @:)
 
-  " Check that getcmdcompltype() doesn't interfere with cmdline completion.
+  " Check that getcmdcompltype() and getcmdcomplpat() don't interfere with
+  " cmdline completion.
   let g:results = []
   cnoremap <F2> <Cmd>let g:results += [[getcmdline()] + Call_cmd_funcs()]<CR>
   call feedkeys(":sign un\<Tab>\<F2>\<Tab>\<F2>\<Tab>\<F2>\<C-C>", "xt")
   call assert_equal([
-        \ ['sign undefine', 14, 15, 'sign'],
-        \ ['sign unplace', 13, 14, 'sign'],
-        \ ['sign un', 8, 9, 'sign']], g:results)
+        \ ['sign undefine', 14, 15, 'sign', 'undefine'],
+        \ ['sign unplace', 13, 14, 'sign', 'unplace'],
+        \ ['sign un', 8, 9, 'sign', 'un']], g:results)
 
   unlet g:results
   cunmap <F2>
index 585ced3e77b2bd2ee61f3de9b69ca5dcd5bc7f21..43409ae227200e62946350a32303a0ccb3e0e3fb 100644 (file)
@@ -92,6 +92,7 @@ static keyvalue_T command_complete_tab[] =
     KEYVALUE_ENTRY(EXPAND_SCRIPTNAMES, "scriptnames"),
 #endif
     KEYVALUE_ENTRY(EXPAND_SHELLCMD, "shellcmd"),
+    KEYVALUE_ENTRY(EXPAND_SHELLCMDLINE, "shellcmdline"),
 #if defined(FEAT_SIGNS)
     KEYVALUE_ENTRY(EXPAND_SIGN, "sign"),
 #endif
@@ -328,7 +329,6 @@ set_context_in_user_cmdarg(
     if (argt & EX_XFILE)
     {
        // EX_XFILE: file names are handled before this call
-       xp->xp_context = context;
        return NULL;
     }
 
@@ -850,7 +850,7 @@ parse_compl_arg(
     *complp = entry->key;
     if (*complp == EXPAND_BUFFERS)
        *argt |= EX_BUFNAME;
-    else if (*complp == EXPAND_DIRECTORIES || *complp == EXPAND_FILES)
+    else if (*complp == EXPAND_DIRECTORIES || *complp == EXPAND_FILES || *complp == EXPAND_SHELLCMDLINE)
        *argt |= EX_XFILE;
 
     if (
index b87fc7870535091402db7db44e1c1a4b0388adab..e949908f087665d66278c6050514859b3f265151 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    770,
 /**/
     769,
 /**/
index ebca6ae85cb965d303f229505813563ca8b431e1..387fe4fd97f7e261975aab7594b584f7401664e9 100644 (file)
--- a/src/vim.h
+++ b/src/vim.h
@@ -844,6 +844,7 @@ extern int (*dyn_libintl_wputenv)(const wchar_t *envstring);
 #define EXPAND_TERMINALOPT     57
 #define EXPAND_KEYMAP          58
 #define EXPAND_DIRS_IN_CDPATH  59
+#define EXPAND_SHELLCMDLINE    60
 
 
 // Values for exmode_active (0 is no exmode)