To: vim_dev@googlegroups.com Subject: Patch 7.4.2331 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ 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) Files: src/edit.c, src/ex_getln.c, src/proto/ex_getln.pro, src/testdir/test_popup.vim *** ../vim-7.4.2330/src/edit.c 2016-08-29 22:48:12.121106421 +0200 --- src/edit.c 2016-09-05 20:53:05.025082101 +0200 *************** *** 5304,5310 **** if (compl_pattern == NULL) return FAIL; set_cmd_context(&compl_xp, compl_pattern, ! (int)STRLEN(compl_pattern), curs_col); if (compl_xp.xp_context == EXPAND_UNSUCCESSFUL || compl_xp.xp_context == EXPAND_NOTHING) /* No completion possible, use an empty pattern to get a --- 5304,5310 ---- if (compl_pattern == NULL) return FAIL; set_cmd_context(&compl_xp, compl_pattern, ! (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 *** ../vim-7.4.2330/src/ex_getln.c 2016-09-03 21:04:54.989247387 +0200 --- src/ex_getln.c 2016-09-05 20:56:00.343600510 +0200 *************** *** 4509,4515 **** xp->xp_context = EXPAND_NOTHING; return; } ! set_cmd_context(xp, ccline.cmdbuff, ccline.cmdlen, ccline.cmdpos); } void --- 4509,4515 ---- xp->xp_context = EXPAND_NOTHING; return; } ! set_cmd_context(xp, ccline.cmdbuff, ccline.cmdlen, ccline.cmdpos, TRUE); } void *************** *** 4517,4523 **** expand_T *xp, char_u *str, /* start of command line */ int len, /* length of command line (excl. NUL) */ ! int col) /* position of cursor */ { int old_char = NUL; char_u *nextcomm; --- 4517,4524 ---- expand_T *xp, char_u *str, /* start of command line */ int len, /* length of command line (excl. NUL) */ ! int col, /* position of cursor */ ! int use_ccline UNUSED) /* use ccline for info */ { int old_char = NUL; char_u *nextcomm; *************** *** 4532,4545 **** nextcomm = str; #ifdef FEAT_EVAL ! if (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) { xp->xp_context = ccline.xp_context; xp->xp_pattern = ccline.cmdbuff; --- 4533,4546 ---- nextcomm = str; #ifdef FEAT_EVAL ! 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 (use_ccline && ccline.input_fn) { xp->xp_context = ccline.xp_context; xp->xp_pattern = ccline.cmdbuff; *** ../vim-7.4.2330/src/proto/ex_getln.pro 2016-09-03 16:29:01.450841139 +0200 --- src/proto/ex_getln.pro 2016-09-05 20:54:23.392419815 +0200 *************** *** 30,36 **** 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); 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); --- 30,36 ---- 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, 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); *** ../vim-7.4.2330/src/testdir/test_popup.vim 2016-09-03 22:35:02.396409822 +0200 --- src/testdir/test_popup.vim 2016-09-05 20:52:36.909316640 +0200 *************** *** 242,263 **** iunmap endfunc - function! ComplTest() abort - call complete(1, ['source', 'soundfold']) - return '' - endfunction - func Test_noinsert_complete() new set completeopt+=noinsert ! inoremap =ComplTest() call feedkeys("i\soun\\\.", 'tx') call assert_equal('soundfold', getline(1)) call assert_equal('soundfold', getline(2)) bwipe! new ! inoremap =Test() call feedkeys("i\\\", 'tx') call assert_equal('source', getline(1)) bwipe! --- 242,268 ---- iunmap endfunc 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 =s:complTest1() call feedkeys("i\soun\\\.", 'tx') call assert_equal('soundfold', getline(1)) call assert_equal('soundfold', getline(2)) bwipe! new ! inoremap =s:complTest2() call feedkeys("i\\\", 'tx') call assert_equal('source', getline(1)) bwipe! *************** *** 266,275 **** iunmap endfunc ! function! Test() abort ! call complete(1, ['source', 'soundfold']) ! return '' ! endfunction " vim: shiftwidth=2 sts=2 expandtab --- 271,290 ---- iunmap endfunc + func Test_compl_vim_cmds_after_register_expr() + function! s:test_func() + return 'autocmd ' + endfunction + augroup AAAAA_Group + au! + augroup END ! 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 *** ../vim-7.4.2330/src/version.c 2016-09-04 23:41:36.973433429 +0200 --- src/version.c 2016-09-05 20:56:08.195534192 +0200 *************** *** 765,766 **** --- 765,768 ---- { /* Add new patch number below this line */ + /**/ + 2331, /**/ -- hundred-and-one symptoms of being an internet addict: 172. You join listservers just for the extra e-mail. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///