]> granicus.if.org Git - vim/commitdiff
patch 7.4.2331 v7.4.2331
authorBram Moolenaar <Bram@vim.org>
Mon, 5 Sep 2016 19:51:14 +0000 (21:51 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 5 Sep 2016 19:51:14 +0000 (21:51 +0200)
Problem:    Using CTRL-X CTRL-V to complete a command line from Insert mode
            does not work after entering an expression on the command line.
Solution:   Don't use "ccline" when not actually using a command line. (test
            by Hirohito Higashi)

src/edit.c
src/ex_getln.c
src/proto/ex_getln.pro
src/testdir/test_popup.vim
src/version.c

index 6d985827a91ea1260ffa5f31345117c7d879a7ea..a87c155c7c589316fda9edd21e04d696fe205a6c 100644 (file)
@@ -5304,7 +5304,7 @@ ins_complete(int c, int enable_pum)
            if (compl_pattern == NULL)
                return FAIL;
            set_cmd_context(&compl_xp, compl_pattern,
-                                    (int)STRLEN(compl_pattern), curs_col);
+                                 (int)STRLEN(compl_pattern), curs_col, FALSE);
            if (compl_xp.xp_context == EXPAND_UNSUCCESSFUL
                    || compl_xp.xp_context == EXPAND_NOTHING)
                /* No completion possible, use an empty pattern to get a
index ed82f0fd3c9620634f074179ea11832ac9cfcc65..4ff9ae17a2c50e1a349cfba80f370f8ad18f877e 100644 (file)
@@ -4509,7 +4509,7 @@ set_expand_context(expand_T *xp)
        xp->xp_context = EXPAND_NOTHING;
        return;
     }
-    set_cmd_context(xp, ccline.cmdbuff, ccline.cmdlen, ccline.cmdpos);
+    set_cmd_context(xp, ccline.cmdbuff, ccline.cmdlen, ccline.cmdpos, TRUE);
 }
 
     void
@@ -4517,7 +4517,8 @@ set_cmd_context(
     expand_T   *xp,
     char_u     *str,       /* start of command line */
     int                len,        /* length of command line (excl. NUL) */
-    int                col)        /* position of cursor */
+    int                col,        /* position of cursor */
+    int                use_ccline UNUSED) /* use ccline for info */
 {
     int                old_char = NUL;
     char_u     *nextcomm;
@@ -4532,14 +4533,14 @@ set_cmd_context(
     nextcomm = str;
 
 #ifdef FEAT_EVAL
-    if (ccline.cmdfirstc == '=')
+    if (use_ccline && ccline.cmdfirstc == '=')
     {
 # ifdef FEAT_CMDL_COMPL
        /* pass CMD_SIZE because there is no real command */
        set_context_for_expression(xp, str, CMD_SIZE);
 # endif
     }
-    else if (ccline.input_fn)
+    else if (use_ccline && ccline.input_fn)
     {
        xp->xp_context = ccline.xp_context;
        xp->xp_pattern = ccline.cmdbuff;
index afc875c598520c2e055e97e2ea7a277677448724..58b635b9fd7481e6161e9af6e000f5e66758087d 100644 (file)
@@ -30,7 +30,7 @@ char_u *vim_strsave_fnameescape(char_u *fname, int shell);
 void tilde_replace(char_u *orig_pat, int num_files, char_u **files);
 char_u *sm_gettail(char_u *s);
 char_u *addstar(char_u *fname, int len, int context);
-void set_cmd_context(expand_T *xp, char_u *str, int len, int col);
+void set_cmd_context(expand_T *xp, char_u *str, int len, int col, int use_ccline);
 int expand_cmdline(expand_T *xp, char_u *str, int col, int *matchcount, char_u ***matches);
 int ExpandGeneric(expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file, char_u *((*func)(expand_T *, int)), int escaped);
 void globpath(char_u *path, char_u *file, garray_T *ga, int expand_options);
index dd949334c8db8d67a374a638fffa5deefe22b6cd..6e0739368561268b239163aaf611c8097360edaa 100644 (file)
@@ -242,22 +242,27 @@ func! Test_popup_completion_insertmode()
   iunmap <F5>
 endfunc
 
-function! ComplTest() abort
-  call complete(1, ['source', 'soundfold'])
-  return ''
-endfunction
-
 func Test_noinsert_complete()
+  function! s:complTest1() abort
+    call complete(1, ['source', 'soundfold'])
+    return ''
+  endfunction
+
+  function! s:complTest2() abort
+    call complete(1, ['source', 'soundfold'])
+    return ''
+  endfunction
+
   new
   set completeopt+=noinsert
-  inoremap <F5>  <C-R>=ComplTest()<CR>
+  inoremap <F5>  <C-R>=s:complTest1()<CR>
   call feedkeys("i\<F5>soun\<CR>\<CR>\<ESC>.", 'tx')
   call assert_equal('soundfold', getline(1))
   call assert_equal('soundfold', getline(2))
   bwipe!
 
   new
-  inoremap <F5>  <C-R>=Test()<CR>
+  inoremap <F5>  <C-R>=s:complTest2()<CR>
   call feedkeys("i\<F5>\<CR>\<ESC>", 'tx')
   call assert_equal('source', getline(1))
   bwipe!
@@ -266,10 +271,20 @@ func Test_noinsert_complete()
   iunmap <F5>
 endfunc
 
+func Test_compl_vim_cmds_after_register_expr()
+  function! s:test_func()
+    return 'autocmd '
+  endfunction
+  augroup AAAAA_Group
+    au!
+  augroup END
 
-function! Test() abort
-  call complete(1, ['source', 'soundfold'])
-  return ''
-endfunction
+  new
+  call feedkeys("i\<c-r>=s:test_func()\<CR>\<C-x>\<C-v>\<Esc>", 'tx')
+  call assert_equal('autocmd AAAAA_Group', getline(1))
+  autocmd! AAAAA_Group
+  augroup! AAAAA_Group
+  bwipe!
+endfunc
 
 " vim: shiftwidth=2 sts=2 expandtab
index 31324c49fe669f3c383cea3e4e2b9f623a8ad118..740d978e90861301d163496aded9a924a58e03b6 100644 (file)
@@ -763,6 +763,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2331,
 /**/
     2330,
 /**/