complete: noinsert/noselect should not set 'modified'. #4509

This commit is contained in:
Shougo Matsushita 2016-03-31 20:52:56 +09:00 committed by Justin M. Keyes
parent 5330aa104b
commit d227c843bf
2 changed files with 19 additions and 6 deletions

View File

@ -2358,13 +2358,13 @@ void set_completion(colnr_T startcol, list_T *list)
int save_w_wrow = curwin->w_wrow; int save_w_wrow = curwin->w_wrow;
compl_curr_match = compl_first_match; compl_curr_match = compl_first_match;
if (compl_no_insert) { if (compl_no_insert || compl_no_select) {
ins_complete(K_DOWN, false); ins_complete(K_DOWN, false);
if (compl_no_select) {
ins_complete(K_UP, false);
}
} else { } else {
ins_complete(Ctrl_N, false); ins_complete(Ctrl_N, false);
if (compl_no_select) {
ins_complete(Ctrl_P, false);
}
} }
// Lazily show the popup menu, unless we got interrupted. // Lazily show the popup menu, unless we got interrupted.
@ -4239,9 +4239,10 @@ void ins_compl_check_keys(int frequency)
static int ins_compl_key2dir(int c) static int ins_compl_key2dir(int c)
{ {
if (c == Ctrl_P || c == Ctrl_L if (c == Ctrl_P || c == Ctrl_L
|| (pum_visible() && (c == K_PAGEUP || c == K_KPAGEUP || c == K_PAGEUP || c == K_KPAGEUP
|| c == K_S_UP || c == K_UP))) || c == K_S_UP || c == K_UP) {
return BACKWARD; return BACKWARD;
}
return FORWARD; return FORWARD;
} }

View File

@ -100,6 +100,18 @@ describe('completion', function()
feed('o<C-r>=TestComplete()<CR><ESC>') feed('o<C-r>=TestComplete()<CR><ESC>')
eq('', eval('getline(3)')) eq('', eval('getline(3)'))
end) end)
it('does not change modified state if noinsert', function()
execute('set completeopt+=menuone,noinsert')
execute('setlocal nomodified')
feed('i<C-r>=TestComplete()<CR><ESC>')
eq(0, eval('&l:modified'))
end)
it('does not change modified state if noselect', function()
execute('set completeopt+=menuone,noselect')
execute('setlocal nomodified')
feed('i<C-r>=TestComplete()<CR><ESC>')
eq(0, eval('&l:modified'))
end)
end) end)
describe("refresh:always", function() describe("refresh:always", function()