mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
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:
@@ -2799,9 +2799,6 @@ set_completion(colnr_T startcol, list_T *list)
|
|||||||
ins_compl_prep(' ');
|
ins_compl_prep(' ');
|
||||||
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;
|
||||||
@@ -3876,7 +3873,8 @@ ins_compl_prep(int c)
|
|||||||
/* 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)
|
/* only format when something was inserted */
|
||||||
|
if (!arrow_used && !ins_need_undo)
|
||||||
insertchar(NUL, 0, -1);
|
insertchar(NUL, 0, -1);
|
||||||
if (prev_col > 0
|
if (prev_col > 0
|
||||||
&& ml_get_curline()[curwin->w_cursor.col] != NUL)
|
&& ml_get_curline()[curwin->w_cursor.col] != NUL)
|
||||||
|
@@ -378,7 +378,7 @@ func DummyCompleteFour(findstart, base)
|
|||||||
endif
|
endif
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
:"Test that 'completefunc' works when it's OK.
|
" Test that 'completefunc' works when it's OK.
|
||||||
func Test_omnifunc_with_check()
|
func Test_omnifunc_with_check()
|
||||||
new
|
new
|
||||||
setlocal omnifunc=DummyCompleteFour
|
setlocal omnifunc=DummyCompleteFour
|
||||||
@@ -400,4 +400,30 @@ func Test_omnifunc_with_check()
|
|||||||
q!
|
q!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
function UndoComplete()
|
||||||
|
call complete(1, ['January', 'February', 'March',
|
||||||
|
\ 'April', 'May', 'June', 'July', 'August', 'September',
|
||||||
|
\ 'October', 'November', 'December'])
|
||||||
|
return ''
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Test that no undo item is created when no completion is inserted
|
||||||
|
func Test_complete_no_undo()
|
||||||
|
set completeopt=menu,preview,noinsert,noselect
|
||||||
|
inoremap <Right> <C-R>=UndoComplete()<CR>
|
||||||
|
new
|
||||||
|
call feedkeys("ixxx\<CR>\<CR>yyy\<Esc>k", 'xt')
|
||||||
|
call feedkeys("iaaa\<Esc>0", 'xt')
|
||||||
|
call assert_equal('aaa', getline(2))
|
||||||
|
call feedkeys("i\<Right>\<Esc>", 'xt')
|
||||||
|
call assert_equal('aaa', getline(2))
|
||||||
|
call feedkeys("u", 'xt')
|
||||||
|
call assert_equal('', getline(2))
|
||||||
|
|
||||||
|
iunmap <Right>
|
||||||
|
set completeopt&
|
||||||
|
q!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -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 */
|
||||||
|
/**/
|
||||||
|
41,
|
||||||
/**/
|
/**/
|
||||||
40,
|
40,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user