Skip to content

Commit

Permalink
patch 8.0.1731: characters deleted on completion
Browse files Browse the repository at this point in the history
Problem:    Characters deleted on completion. (Adrià Farrés)
Solution:   Also check the last item for the ORIGINAL_TEXT flag. (Christian
            Brabandt, closes #1645)
  • Loading branch information
brammool committed Apr 17, 2018
1 parent 561f8a5 commit e87edf3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/edit.c
Original file line number Diff line number Diff line change
Expand Up @@ -3656,7 +3656,9 @@ ins_compl_set_original_text(char_u *str)
{
char_u *p;

/* Replace the original text entry. */
/* Replace the original text entry.
* The ORIGINAL_TEXT flag is either at the first item or might possibly be
* at the last item for backward completion */
if (compl_first_match->cp_flags & ORIGINAL_TEXT) /* safety check */
{
p = vim_strsave(str);
Expand All @@ -3666,6 +3668,16 @@ ins_compl_set_original_text(char_u *str)
compl_first_match->cp_str = p;
}
}
else if (compl_first_match->cp_prev != NULL
&& (compl_first_match->cp_prev->cp_flags & ORIGINAL_TEXT))
{
p = vim_strsave(str);
if (p != NULL)
{
vim_free(compl_first_match->cp_prev->cp_str);
compl_first_match->cp_prev->cp_str = p;
}
}
}

/*
Expand Down
9 changes: 9 additions & 0 deletions src/testdir/test_popup.vim
Original file line number Diff line number Diff line change
Expand Up @@ -814,5 +814,14 @@ func Test_popup_command()
call delete('Xtest')
endfunc

func Test_popup_complete_backwards()
new
call setline(1, ['Post', 'Port', 'Po'])
let expected=['Post', 'Port', 'Port']
call cursor(3,2)
call feedkeys("A\<C-X>". repeat("\<C-P>", 3). "rt\<cr>", 'tx')
call assert_equal(expected, getline(1,'$'))
bwipe!
endfunc

" vim: shiftwidth=2 sts=2 expandtab
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1731,
/**/
1730,
/**/
Expand Down

0 comments on commit e87edf3

Please sign in to comment.