Skip to content

Commit d099e03

Browse files
committed
patch 8.0.0347: when using completion comment leader wont work
Problem: When using CTRL-X CTRL-U inside a comment, the use of the comment leader may not work. (Klement) Solution: Save and restore did_ai. (Christian Brabandt, closes #1494)
1 parent bfd3059 commit d099e03

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

src/edit.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5095,6 +5095,7 @@ ins_complete(int c, int enable_pum)
50955095
int n;
50965096
int save_w_wrow;
50975097
int insert_match;
5098+
int save_did_ai = did_ai;
50985099

50995100
compl_direction = ins_compl_key2dir(c);
51005101
insert_match = ins_compl_use_match(c);
@@ -5378,6 +5379,8 @@ ins_complete(int c, int enable_pum)
53785379
{
53795380
EMSG2(_(e_notset), ctrl_x_mode == CTRL_X_FUNCTION
53805381
? "completefunc" : "omnifunc");
5382+
/* restore did_ai, so that adding comment leader works */
5383+
did_ai = save_did_ai;
53815384
return FAIL;
53825385
}
53835386

src/testdir/test_popup.vim

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,4 +551,23 @@ func Test_completion_can_undo()
551551
iunmap <Right>
552552
endfunc
553553

554+
func Test_completion_comment_formatting()
555+
new
556+
setl formatoptions=tcqro
557+
call feedkeys("o/*\<cr>\<cr>/\<esc>", 'tx')
558+
call assert_equal(['', '/*', ' *', ' */'], getline(1,4))
559+
%d
560+
call feedkeys("o/*\<cr>foobar\<cr>/\<esc>", 'tx')
561+
call assert_equal(['', '/*', ' * foobar', ' */'], getline(1,4))
562+
%d
563+
try
564+
call feedkeys("o/*\<cr>\<cr>\<c-x>\<c-u>/\<esc>", 'tx')
565+
call assert_false(1, 'completefunc not set, should have failed')
566+
catch
567+
call assert_exception('E764:')
568+
endtry
569+
call assert_equal(['', '/*', ' *', ' */'], getline(1,4))
570+
bwipe!
571+
endfunc
572+
554573
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

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

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
347,
767769
/**/
768770
346,
769771
/**/

0 commit comments

Comments
 (0)