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: #18260

Signed-off-by: Girish Palya <girishji@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Girish Palya
2025-09-15 19:01:01 +00:00
committed by Christian Brabandt
parent ba36510920
commit 5c9b71d63c
4 changed files with 26 additions and 1 deletions

View File

@ -2424,6 +2424,10 @@ ins_compl_bs(void)
return K_BS;
}
// 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();
if (compl_shown_match != NULL)
// Make sure current match is not a hidden item.

View File

@ -5247,6 +5247,21 @@ func Test_autocomplete_trigger()
call feedkeys("Sazx\<Left>\<BS>\<F2>\<Esc>0", 'tx!')
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!
call test_override("char_avail", 0)
delfunc NonKeywordComplete

View File

@ -724,6 +724,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1762,
/**/
1761,
/**/