mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 11:28:22 +00:00
vim-patch:8.0.1731: characters deleted on completion
Problem: Characters deleted on completion. (Adrià Farrés)
Solution: Also check the last item for the ORIGINAL_TEXT flag. (Christian
Brabandt, closes vim/vim#1645)
e87edf3b85
This commit is contained in:
@@ -3127,10 +3127,16 @@ static void ins_compl_restart(void)
|
|||||||
*/
|
*/
|
||||||
static void ins_compl_set_original_text(char_u *str)
|
static void ins_compl_set_original_text(char_u *str)
|
||||||
{
|
{
|
||||||
/* Replace the original text entry. */
|
// Replace the original text entry.
|
||||||
if (compl_first_match->cp_flags & ORIGINAL_TEXT) { /* safety check */
|
// 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
|
||||||
xfree(compl_first_match->cp_str);
|
xfree(compl_first_match->cp_str);
|
||||||
compl_first_match->cp_str = vim_strsave(str);
|
compl_first_match->cp_str = vim_strsave(str);
|
||||||
|
} else if (compl_first_match->cp_prev != NULL
|
||||||
|
&& (compl_first_match->cp_prev->cp_flags & ORIGINAL_TEXT)) {
|
||||||
|
xfree(compl_first_match->cp_prev->cp_str);
|
||||||
|
compl_first_match->cp_prev->cp_str = vim_strsave(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -571,6 +571,15 @@ func Test_completion_clear_candidate_list()
|
|||||||
bw!
|
bw!
|
||||||
endfunc
|
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
|
||||||
|
|
||||||
func Test_popup_and_preview_autocommand()
|
func Test_popup_and_preview_autocommand()
|
||||||
" This used to crash Vim
|
" This used to crash Vim
|
||||||
|
Reference in New Issue
Block a user