Skip to content

Commit 9ec7fa8

Browse files
committed
patch 8.0.0043
Problem: When using Insert mode completion with 'completeopt' containing "noinsert" with CTRL-N the change is not saved for undo. (Tommy Allen) Solution: Call stop_arrow() before inserting for any key.
1 parent cbd3bd6 commit 9ec7fa8

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

src/edit.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4634,14 +4634,19 @@ ins_compl_get_exp(pos_T *ini)
46344634
static void
46354635
ins_compl_delete(void)
46364636
{
4637-
int i;
4637+
int col;
46384638

46394639
/*
46404640
* In insert mode: Delete the typed part.
46414641
* In replace mode: Put the old characters back, if any.
46424642
*/
4643-
i = compl_col + (compl_cont_status & CONT_ADDING ? compl_length : 0);
4644-
backspace_until_column(i);
4643+
col = compl_col + (compl_cont_status & CONT_ADDING ? compl_length : 0);
4644+
if ((int)curwin->w_cursor.col > col)
4645+
{
4646+
if (stop_arrow() == FAIL)
4647+
return;
4648+
backspace_until_column(col);
4649+
}
46454650

46464651
/* TODO: is this sufficient for redrawing? Redrawing everything causes
46474652
* flicker, thus we can't do that. */
@@ -5059,8 +5064,11 @@ ins_complete(int c, int enable_pum)
50595064
colnr_T curs_col; /* cursor column */
50605065
int n;
50615066
int save_w_wrow;
5067+
int insert_match;
50625068

50635069
compl_direction = ins_compl_key2dir(c);
5070+
insert_match = ins_compl_use_match(c);
5071+
50645072
if (!compl_started)
50655073
{
50665074
/* First time we hit ^N or ^P (in a row, I mean) */
@@ -5486,6 +5494,8 @@ ins_complete(int c, int enable_pum)
54865494
edit_submode_extra = NULL;
54875495
out_flush();
54885496
}
5497+
else if (insert_match && stop_arrow() == FAIL)
5498+
return FAIL;
54895499

54905500
compl_shown_match = compl_curr_match;
54915501
compl_shows_dir = compl_direction;
@@ -5494,8 +5504,7 @@ ins_complete(int c, int enable_pum)
54945504
* Find next match (and following matches).
54955505
*/
54965506
save_w_wrow = curwin->w_wrow;
5497-
n = ins_compl_next(TRUE, ins_compl_key2count(c),
5498-
ins_compl_use_match(c), FALSE);
5507+
n = ins_compl_next(TRUE, ins_compl_key2count(c), insert_match, FALSE);
54995508

55005509
/* may undisplay the popup menu */
55015510
ins_compl_upd_pum();

src/testdir/test_popup.vim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,11 @@ func Test_complete_no_undo()
427427
call feedkeys("u", 'xt')
428428
call assert_equal('bbb', getline(2))
429429

430+
call feedkeys("A\<Right>\<C-N>\<Esc>", 'xt')
431+
call assert_equal('January', getline(2))
432+
call feedkeys("u", 'xt')
433+
call assert_equal('bbb', getline(2))
434+
430435
iunmap <Right>
431436
set completeopt&
432437
q!

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+
43,
767769
/**/
768770
42,
769771
/**/

0 commit comments

Comments
 (0)