mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 8.0.0341: undo does not work properly when using completion
Problem: When using complete() and typing a character undo is saved after the character was inserted. (Shougo) Solution: Save for undo before inserting the character.
This commit is contained in:
@@ -3583,7 +3583,11 @@ ins_compl_addleader(int c)
|
|||||||
{
|
{
|
||||||
#ifdef FEAT_MBYTE
|
#ifdef FEAT_MBYTE
|
||||||
int cc;
|
int cc;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (stop_arrow() == FAIL)
|
||||||
|
return;
|
||||||
|
#ifdef FEAT_MBYTE
|
||||||
if (has_mbyte && (cc = (*mb_char2len)(c)) > 1)
|
if (has_mbyte && (cc = (*mb_char2len)(c)) > 1)
|
||||||
{
|
{
|
||||||
char_u buf[MB_MAXBYTES + 1];
|
char_u buf[MB_MAXBYTES + 1];
|
||||||
|
@@ -531,4 +531,24 @@ func Test_completion_respect_bs_option()
|
|||||||
bw!
|
bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func CompleteUndo() abort
|
||||||
|
call complete(1, g:months)
|
||||||
|
return ''
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_completion_can_undo()
|
||||||
|
inoremap <Right> <c-r>=CompleteUndo()<cr>
|
||||||
|
set completeopt+=noinsert,noselect
|
||||||
|
|
||||||
|
new
|
||||||
|
call feedkeys("a\<Right>a\<Esc>", 'xt')
|
||||||
|
call assert_equal('a', getline(1))
|
||||||
|
undo
|
||||||
|
call assert_equal('', getline(1))
|
||||||
|
|
||||||
|
bwipe!
|
||||||
|
set completeopt&
|
||||||
|
iunmap <Right>
|
||||||
|
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 */
|
||||||
|
/**/
|
||||||
|
341,
|
||||||
/**/
|
/**/
|
||||||
340,
|
340,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user