mirror of
https://github.com/neovim/neovim.git
synced 2025-10-18 07:41:51 +00:00
vim-patch:9.1.1762: completion: selected item not cleared on <BS> with 'ac'
Problem: completion: selected item not cleared on backspace when
'autocomplete' is set
Solution: Clear the selected item (Girish Palya)
closes: vim/vim#18260
5c9b71d63c
Co-authored-by: Girish Palya <girishji@gmail.com>
This commit is contained in:
@@ -1368,6 +1368,8 @@ In the first state these keys have a special meaning:
|
|||||||
<BS> and CTRL-H Delete one character, find the matches for the word before
|
<BS> and CTRL-H Delete one character, find the matches for the word before
|
||||||
the cursor. This reduces the list of matches, often to one
|
the cursor. This reduces the list of matches, often to one
|
||||||
entry, and switches to the second state.
|
entry, and switches to the second state.
|
||||||
|
When 'autocomplete' is set, clears the selected item in the
|
||||||
|
menu.
|
||||||
Any non-special character:
|
Any non-special character:
|
||||||
Stop completion without changing the match and insert the
|
Stop completion without changing the match and insert the
|
||||||
typed character.
|
typed character.
|
||||||
@@ -1375,6 +1377,8 @@ Any non-special character:
|
|||||||
In the second and third state these keys have a special meaning:
|
In the second and third state these keys have a special meaning:
|
||||||
<BS> and CTRL-H Delete one character, find the matches for the shorter word
|
<BS> and CTRL-H Delete one character, find the matches for the shorter word
|
||||||
before the cursor. This may find more matches.
|
before the cursor. This may find more matches.
|
||||||
|
When 'autocomplete' is set, clears the selected item in the
|
||||||
|
menu.
|
||||||
CTRL-L Add one character from the current match, may reduce the
|
CTRL-L Add one character from the current match, may reduce the
|
||||||
number of matches.
|
number of matches.
|
||||||
any printable, non-white character:
|
any printable, non-white character:
|
||||||
|
@@ -2197,6 +2197,11 @@ int ins_compl_bs(void)
|
|||||||
compl_leader = cbuf_to_string(line + compl_col,
|
compl_leader = cbuf_to_string(line + compl_col,
|
||||||
(size_t)(p_off - (ptrdiff_t)compl_col));
|
(size_t)(p_off - (ptrdiff_t)compl_col));
|
||||||
|
|
||||||
|
// Clear selection if a menu item is currently selected in autocompletion
|
||||||
|
if (compl_autocomplete && compl_first_match) {
|
||||||
|
compl_shown_match = compl_first_match;
|
||||||
|
}
|
||||||
|
|
||||||
ins_compl_new_leader();
|
ins_compl_new_leader();
|
||||||
if (compl_shown_match != NULL) {
|
if (compl_shown_match != NULL) {
|
||||||
// Make sure current match is not a hidden item.
|
// Make sure current match is not a hidden item.
|
||||||
|
@@ -5359,6 +5359,21 @@ func Test_autocomplete_trigger()
|
|||||||
call feedkeys("Sazx\<Left>\<BS>\<F2>\<Esc>0", 'tx!')
|
call feedkeys("Sazx\<Left>\<BS>\<F2>\<Esc>0", 'tx!')
|
||||||
call assert_equal(['and', 'afoo'], b:matches->mapnew('v:val.word'))
|
call assert_equal(['and', 'afoo'], b:matches->mapnew('v:val.word'))
|
||||||
|
|
||||||
|
" Test 6: <BS> should clear the selected item
|
||||||
|
%d
|
||||||
|
call setline(1, ["foobarfoo", "foobar", "foobarbaz"])
|
||||||
|
call feedkeys("Gofo\<C-N>\<C-N>\<F2>\<F3>\<Esc>0", 'tx!')
|
||||||
|
call assert_equal(['foobarbaz', 'foobar', 'foobarfoo'], b:matches->mapnew('v:val.word'))
|
||||||
|
call assert_equal(1, b:selected)
|
||||||
|
call feedkeys("Sfo\<C-N>\<C-N>\<BS>\<F2>\<F3>\<Esc>0", 'tx!')
|
||||||
|
call assert_equal(['foobarbaz', 'foobar', 'foobarfoo'], b:matches->mapnew('v:val.word'))
|
||||||
|
call assert_equal(-1, b:selected)
|
||||||
|
call assert_equal('fooba', getline(4))
|
||||||
|
call feedkeys("Sfo\<C-N>\<C-N>\<BS>\<C-N>\<F2>\<F3>\<Esc>0", 'tx!')
|
||||||
|
call assert_equal(['foobarbaz', 'foobar', 'foobarfoo'], b:matches->mapnew('v:val.word'))
|
||||||
|
call assert_equal(0, b:selected)
|
||||||
|
call assert_equal('foobarbaz', getline(4))
|
||||||
|
|
||||||
bw!
|
bw!
|
||||||
call Ntest_override("char_avail", 0)
|
call Ntest_override("char_avail", 0)
|
||||||
delfunc NonKeywordComplete
|
delfunc NonKeywordComplete
|
||||||
|
Reference in New Issue
Block a user