mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00:00
vim-patch:9.1.1127: preinsert text is not cleaned up correctly (#32544)
Problem: when 'completeopt' is set to preinsert the preinserted text is
not cleared when adding new leader (Yee Cheng Chin)
Solution: add a condition to delete preinsert text in edit function
(glepnir)
closes: vim/vim#16672
52fd867f5e
Co-authored-by: glepnir <glephunter@gmail.com>
This commit is contained in:
@@ -562,10 +562,10 @@ static int insert_execute(VimState *state, int key)
|
|||||||
// Special handling of keys while the popup menu is visible or wanted
|
// Special handling of keys while the popup menu is visible or wanted
|
||||||
// and the cursor is still in the completed word. Only when there is
|
// and the cursor is still in the completed word. Only when there is
|
||||||
// a match, skip this when no matches were found.
|
// a match, skip this when no matches were found.
|
||||||
if (ins_compl_active()
|
bool ins_completion = ins_compl_active()
|
||||||
&& pum_wanted()
|
&& curwin->w_cursor.col >= ins_compl_col()
|
||||||
&& curwin->w_cursor.col >= ins_compl_col()
|
&& ins_compl_has_shown_match();
|
||||||
&& ins_compl_has_shown_match()) {
|
if (ins_completion && pum_wanted()) {
|
||||||
// BS: Delete one character from "compl_leader".
|
// BS: Delete one character from "compl_leader".
|
||||||
if ((s->c == K_BS || s->c == Ctrl_H)
|
if ((s->c == K_BS || s->c == Ctrl_H)
|
||||||
&& curwin->w_cursor.col > ins_compl_col()
|
&& curwin->w_cursor.col > ins_compl_col()
|
||||||
@@ -615,6 +615,8 @@ static int insert_execute(VimState *state, int key)
|
|||||||
ins_compl_delete(false);
|
ins_compl_delete(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (ins_completion && !pum_wanted() && ins_compl_preinsert_effect()) {
|
||||||
|
ins_compl_delete(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare for or stop CTRL-X mode. This doesn't do completion, but it does
|
// Prepare for or stop CTRL-X mode. This doesn't do completion, but it does
|
||||||
|
@@ -3110,6 +3110,11 @@ function Test_completeopt_preinsert()
|
|||||||
call assert_equal("fobar", getline('.'))
|
call assert_equal("fobar", getline('.'))
|
||||||
call assert_equal(5, col('.'))
|
call assert_equal(5, col('.'))
|
||||||
|
|
||||||
|
set cot=preinsert
|
||||||
|
call feedkeys("Sfoo1 foo2\<CR>f\<C-X>\<C-N>bar", 'tx')
|
||||||
|
call assert_equal("fbar", getline('.'))
|
||||||
|
call assert_equal(4, col('.'))
|
||||||
|
|
||||||
bw!
|
bw!
|
||||||
set cot&
|
set cot&
|
||||||
set omnifunc&
|
set omnifunc&
|
||||||
|
Reference in New Issue
Block a user