0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

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.
This commit is contained in:
Bram Moolenaar
2016-10-18 13:06:41 +02:00
parent cbd3bd6cbe
commit 9ec7fa82a2
3 changed files with 21 additions and 5 deletions

View File

@@ -4634,14 +4634,19 @@ ins_compl_get_exp(pos_T *ini)
static void static void
ins_compl_delete(void) ins_compl_delete(void)
{ {
int i; int col;
/* /*
* In insert mode: Delete the typed part. * In insert mode: Delete the typed part.
* In replace mode: Put the old characters back, if any. * In replace mode: Put the old characters back, if any.
*/ */
i = compl_col + (compl_cont_status & CONT_ADDING ? compl_length : 0); col = compl_col + (compl_cont_status & CONT_ADDING ? compl_length : 0);
backspace_until_column(i); if ((int)curwin->w_cursor.col > col)
{
if (stop_arrow() == FAIL)
return;
backspace_until_column(col);
}
/* TODO: is this sufficient for redrawing? Redrawing everything causes /* TODO: is this sufficient for redrawing? Redrawing everything causes
* flicker, thus we can't do that. */ * flicker, thus we can't do that. */
@@ -5059,8 +5064,11 @@ ins_complete(int c, int enable_pum)
colnr_T curs_col; /* cursor column */ colnr_T curs_col; /* cursor column */
int n; int n;
int save_w_wrow; int save_w_wrow;
int insert_match;
compl_direction = ins_compl_key2dir(c); compl_direction = ins_compl_key2dir(c);
insert_match = ins_compl_use_match(c);
if (!compl_started) if (!compl_started)
{ {
/* First time we hit ^N or ^P (in a row, I mean) */ /* First time we hit ^N or ^P (in a row, I mean) */
@@ -5486,6 +5494,8 @@ ins_complete(int c, int enable_pum)
edit_submode_extra = NULL; edit_submode_extra = NULL;
out_flush(); out_flush();
} }
else if (insert_match && stop_arrow() == FAIL)
return FAIL;
compl_shown_match = compl_curr_match; compl_shown_match = compl_curr_match;
compl_shows_dir = compl_direction; compl_shows_dir = compl_direction;
@@ -5494,8 +5504,7 @@ ins_complete(int c, int enable_pum)
* Find next match (and following matches). * Find next match (and following matches).
*/ */
save_w_wrow = curwin->w_wrow; save_w_wrow = curwin->w_wrow;
n = ins_compl_next(TRUE, ins_compl_key2count(c), n = ins_compl_next(TRUE, ins_compl_key2count(c), insert_match, FALSE);
ins_compl_use_match(c), FALSE);
/* may undisplay the popup menu */ /* may undisplay the popup menu */
ins_compl_upd_pum(); ins_compl_upd_pum();

View File

@@ -427,6 +427,11 @@ func Test_complete_no_undo()
call feedkeys("u", 'xt') call feedkeys("u", 'xt')
call assert_equal('bbb', getline(2)) call assert_equal('bbb', getline(2))
call feedkeys("A\<Right>\<C-N>\<Esc>", 'xt')
call assert_equal('January', getline(2))
call feedkeys("u", 'xt')
call assert_equal('bbb', getline(2))
iunmap <Right> iunmap <Right>
set completeopt& set completeopt&
q! q!

View File

@@ -764,6 +764,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
43,
/**/ /**/
42, 42,
/**/ /**/