Skip to content

Commit 33a80ee

Browse files
committed
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)
1 parent 030cddc commit 33a80ee

5 files changed

Lines changed: 35 additions & 17 deletions

File tree

src/edit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5304,7 +5304,7 @@ ins_complete(int c, int enable_pum)
53045304
if (compl_pattern == NULL)
53055305
return FAIL;
53065306
set_cmd_context(&compl_xp, compl_pattern,
5307-
(int)STRLEN(compl_pattern), curs_col);
5307+
(int)STRLEN(compl_pattern), curs_col, FALSE);
53085308
if (compl_xp.xp_context == EXPAND_UNSUCCESSFUL
53095309
|| compl_xp.xp_context == EXPAND_NOTHING)
53105310
/* No completion possible, use an empty pattern to get a

src/ex_getln.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4509,15 +4509,16 @@ set_expand_context(expand_T *xp)
45094509
xp->xp_context = EXPAND_NOTHING;
45104510
return;
45114511
}
4512-
set_cmd_context(xp, ccline.cmdbuff, ccline.cmdlen, ccline.cmdpos);
4512+
set_cmd_context(xp, ccline.cmdbuff, ccline.cmdlen, ccline.cmdpos, TRUE);
45134513
}
45144514

45154515
void
45164516
set_cmd_context(
45174517
expand_T *xp,
45184518
char_u *str, /* start of command line */
45194519
int len, /* length of command line (excl. NUL) */
4520-
int col) /* position of cursor */
4520+
int col, /* position of cursor */
4521+
int use_ccline UNUSED) /* use ccline for info */
45214522
{
45224523
int old_char = NUL;
45234524
char_u *nextcomm;
@@ -4532,14 +4533,14 @@ set_cmd_context(
45324533
nextcomm = str;
45334534

45344535
#ifdef FEAT_EVAL
4535-
if (ccline.cmdfirstc == '=')
4536+
if (use_ccline && ccline.cmdfirstc == '=')
45364537
{
45374538
# ifdef FEAT_CMDL_COMPL
45384539
/* pass CMD_SIZE because there is no real command */
45394540
set_context_for_expression(xp, str, CMD_SIZE);
45404541
# endif
45414542
}
4542-
else if (ccline.input_fn)
4543+
else if (use_ccline && ccline.input_fn)
45434544
{
45444545
xp->xp_context = ccline.xp_context;
45454546
xp->xp_pattern = ccline.cmdbuff;

src/proto/ex_getln.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ char_u *vim_strsave_fnameescape(char_u *fname, int shell);
3030
void tilde_replace(char_u *orig_pat, int num_files, char_u **files);
3131
char_u *sm_gettail(char_u *s);
3232
char_u *addstar(char_u *fname, int len, int context);
33-
void set_cmd_context(expand_T *xp, char_u *str, int len, int col);
33+
void set_cmd_context(expand_T *xp, char_u *str, int len, int col, int use_ccline);
3434
int expand_cmdline(expand_T *xp, char_u *str, int col, int *matchcount, char_u ***matches);
3535
int ExpandGeneric(expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file, char_u *((*func)(expand_T *, int)), int escaped);
3636
void globpath(char_u *path, char_u *file, garray_T *ga, int expand_options);

src/testdir/test_popup.vim

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -242,22 +242,27 @@ func! Test_popup_completion_insertmode()
242242
iunmap <F5>
243243
endfunc
244244

245-
function! ComplTest() abort
246-
call complete(1, ['source', 'soundfold'])
247-
return ''
248-
endfunction
249-
250245
func Test_noinsert_complete()
246+
function! s:complTest1() abort
247+
call complete(1, ['source', 'soundfold'])
248+
return ''
249+
endfunction
250+
251+
function! s:complTest2() abort
252+
call complete(1, ['source', 'soundfold'])
253+
return ''
254+
endfunction
255+
251256
new
252257
set completeopt+=noinsert
253-
inoremap <F5> <C-R>=ComplTest()<CR>
258+
inoremap <F5> <C-R>=s:complTest1()<CR>
254259
call feedkeys("i\<F5>soun\<CR>\<CR>\<ESC>.", 'tx')
255260
call assert_equal('soundfold', getline(1))
256261
call assert_equal('soundfold', getline(2))
257262
bwipe!
258263

259264
new
260-
inoremap <F5> <C-R>=Test()<CR>
265+
inoremap <F5> <C-R>=s:complTest2()<CR>
261266
call feedkeys("i\<F5>\<CR>\<ESC>", 'tx')
262267
call assert_equal('source', getline(1))
263268
bwipe!
@@ -266,10 +271,20 @@ func Test_noinsert_complete()
266271
iunmap <F5>
267272
endfunc
268273

274+
func Test_compl_vim_cmds_after_register_expr()
275+
function! s:test_func()
276+
return 'autocmd '
277+
endfunction
278+
augroup AAAAA_Group
279+
au!
280+
augroup END
269281

270-
function! Test() abort
271-
call complete(1, ['source', 'soundfold'])
272-
return ''
273-
endfunction
282+
new
283+
call feedkeys("i\<c-r>=s:test_func()\<CR>\<C-x>\<C-v>\<Esc>", 'tx')
284+
call assert_equal('autocmd AAAAA_Group', getline(1))
285+
autocmd! AAAAA_Group
286+
augroup! AAAAA_Group
287+
bwipe!
288+
endfunc
274289

275290
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,8 @@ static char *(features[]) =
763763

764764
static int included_patches[] =
765765
{ /* Add new patch number below this line */
766+
/**/
767+
2331,
766768
/**/
767769
2330,
768770
/**/

0 commit comments

Comments
 (0)