mirror of
https://github.com/neovim/neovim.git
synced 2025-10-17 15:21:47 +00:00
vim-patch:8.0.0041
Problem: When using Insert mode completion but not actually inserting anything an undo item is still created. (Tommy Allen) Solution: Do not call stop_arrow() when not inserting anything.
This commit is contained in:
@@ -2350,9 +2350,6 @@ void set_completion(colnr_T startcol, list_T *list)
|
|||||||
}
|
}
|
||||||
ins_compl_clear();
|
ins_compl_clear();
|
||||||
|
|
||||||
if (stop_arrow() == FAIL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
compl_direction = FORWARD;
|
compl_direction = FORWARD;
|
||||||
if (startcol > curwin->w_cursor.col)
|
if (startcol > curwin->w_cursor.col)
|
||||||
startcol = curwin->w_cursor.col;
|
startcol = curwin->w_cursor.col;
|
||||||
@@ -3263,14 +3260,19 @@ static bool ins_compl_prep(int c)
|
|||||||
} else {
|
} else {
|
||||||
int prev_col = curwin->w_cursor.col;
|
int prev_col = curwin->w_cursor.col;
|
||||||
|
|
||||||
/* put the cursor on the last char, for 'tw' formatting */
|
// put the cursor on the last char, for 'tw' formatting
|
||||||
if (prev_col > 0)
|
if (prev_col > 0) {
|
||||||
dec_cursor();
|
dec_cursor();
|
||||||
if (stop_arrow() == OK)
|
}
|
||||||
|
|
||||||
|
if (!arrow_used && !ins_need_undo) {
|
||||||
insertchar(NUL, 0, -1);
|
insertchar(NUL, 0, -1);
|
||||||
|
}
|
||||||
|
|
||||||
if (prev_col > 0
|
if (prev_col > 0
|
||||||
&& get_cursor_line_ptr()[curwin->w_cursor.col] != NUL)
|
&& get_cursor_line_ptr()[curwin->w_cursor.col] != NUL) {
|
||||||
inc_cursor();
|
inc_cursor();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the popup menu is displayed pressing CTRL-Y means accepting
|
// If the popup menu is displayed pressing CTRL-Y means accepting
|
||||||
|
@@ -317,6 +317,62 @@ describe('completion', function()
|
|||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
describe('completeopt+=noinsert does not add blank undo items', function()
|
||||||
|
before_each(function()
|
||||||
|
source([[
|
||||||
|
function! TestComplete() abort
|
||||||
|
call complete(1, ['foo', 'bar'])
|
||||||
|
return ''
|
||||||
|
endfunction
|
||||||
|
]])
|
||||||
|
execute('set completeopt+=noselect,noinsert')
|
||||||
|
execute('inoremap <right> <c-r>=TestComplete()<cr>')
|
||||||
|
end)
|
||||||
|
|
||||||
|
local tests = {
|
||||||
|
['<up>, <down>, <cr>'] = {'<down><cr>', '<up><cr>'},
|
||||||
|
['<c-n>, <c-p>, <c-y>'] = {'<c-n><c-y>', '<c-p><c-y>'},
|
||||||
|
}
|
||||||
|
|
||||||
|
for name, seq in pairs(tests) do
|
||||||
|
it('using ' .. name, function()
|
||||||
|
feed('iaaa<esc>')
|
||||||
|
feed('A<right>' .. seq[1] .. '<esc>')
|
||||||
|
feed('A<right><esc>A<right><esc>')
|
||||||
|
feed('A<cr>bbb<esc>')
|
||||||
|
feed('A<right>' .. seq[2] .. '<esc>')
|
||||||
|
feed('A<right><esc>A<right><esc>')
|
||||||
|
feed('A<cr>ccc<esc>')
|
||||||
|
feed('A<right>' .. seq[1] .. '<esc>')
|
||||||
|
feed('A<right><esc>A<right><esc>')
|
||||||
|
|
||||||
|
local expected = {
|
||||||
|
{'foo', 'bar', 'foo'},
|
||||||
|
{'foo', 'bar', 'ccc'},
|
||||||
|
{'foo', 'bar'},
|
||||||
|
{'foo', 'bbb'},
|
||||||
|
{'foo'},
|
||||||
|
{'aaa'},
|
||||||
|
{''},
|
||||||
|
}
|
||||||
|
|
||||||
|
for i = 1, #expected do
|
||||||
|
if i > 1 then
|
||||||
|
feed('u')
|
||||||
|
end
|
||||||
|
eq(expected[i], eval('getline(1, "$")'))
|
||||||
|
end
|
||||||
|
|
||||||
|
for i = #expected, 1, -1 do
|
||||||
|
if i < #expected then
|
||||||
|
feed('<c-r>')
|
||||||
|
end
|
||||||
|
eq(expected[i], eval('getline(1, "$")'))
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
describe("refresh:always", function()
|
describe("refresh:always", function()
|
||||||
before_each(function()
|
before_each(function()
|
||||||
source([[
|
source([[
|
||||||
|
Reference in New Issue
Block a user