# HG changeset patch # User Christian Brabandt # Date 1473105606 -7200 # Node ID fb040c9d8ce9c0df6e011fca76a1a377e40ad956 # Parent ed2477b5d292f8455f03f4b55bd9239d7bb1be94 commit https://github.com/vim/vim/commit/33a80eeb859a78ba93432da6fa585786cfd77249 Author: Bram Moolenaar Date: Mon Sep 5 21:51:14 2016 +0200 patch 7.4.2331 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) diff --git a/src/edit.c b/src/edit.c --- a/src/edit.c +++ b/src/edit.c @@ -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 diff --git a/src/ex_getln.c b/src/ex_getln.c --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -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; diff --git a/src/proto/ex_getln.pro b/src/proto/ex_getln.pro --- a/src/proto/ex_getln.pro +++ b/src/proto/ex_getln.pro @@ -30,7 +30,7 @@ char_u *vim_strsave_fnameescape(char_u * 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); diff --git a/src/testdir/test_popup.vim b/src/testdir/test_popup.vim --- a/src/testdir/test_popup.vim +++ b/src/testdir/test_popup.vim @@ -242,22 +242,27 @@ func! Test_popup_completion_insertmode() iunmap 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 -func Test_noinsert_complete() + function! s:complTest2() abort + call complete(1, ['source', 'soundfold']) + return '' + endfunction + new set completeopt+=noinsert - inoremap =ComplTest() + inoremap =s:complTest1() call feedkeys("i\soun\\\.", 'tx') call assert_equal('soundfold', getline(1)) call assert_equal('soundfold', getline(2)) bwipe! new - inoremap =Test() + inoremap =s:complTest2() call feedkeys("i\\\", 'tx') call assert_equal('source', getline(1)) bwipe! @@ -266,10 +271,20 @@ func Test_noinsert_complete() iunmap 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\=s:test_func()\\\\", 'tx') + call assert_equal('autocmd AAAAA_Group', getline(1)) + autocmd! AAAAA_Group + augroup! AAAAA_Group + bwipe! +endfunc " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2331, +/**/ 2330, /**/ 2329,