Skip to content

Commit 57f9ce1

Browse files
committed
patch 9.0.2090: complete_info() skips entries with 'noselect'
Problem: complete_info() skips entries with 'noselect' Solution: Check, if first entry is at original text state Unfortunately, Commit daef8c7 introduced a regression, that when ':set completeopt+=noselect' is set and no completion item has been selected yet, it did not fill the complete_info['items'] list. This happened, because the current match item did not have the CP_ORIGINAL_TEXT flag set and then the cp->prev pointer did point to the original flag item, which caused the following while loop to not being run but being skipped instead. So when the 'noselect' is set, only start with to the previous selection item, if the initial completion item has the CP_ORIGINAL_TEXT flag set, else use the 2nd previous item instead. fixes: #13451 closes: #13452 Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent b23c1fc commit 57f9ce1

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/insexpand.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3080,7 +3080,7 @@ info_add_completion_info(list_T *li)
30803080

30813081
// Skip the element with the CP_ORIGINAL_TEXT flag at the beginning, in case of
30823082
// forward completion, or at the end, in case of backward completion.
3083-
match = forward ? match->cp_next : (compl_no_select ? match->cp_prev : match->cp_prev->cp_prev);
3083+
match = forward ? match->cp_next : (compl_no_select && match_at_original_text(match) ? match->cp_prev : match->cp_prev->cp_prev);
30843084

30853085
while (match != NULL && !match_at_original_text(match))
30863086
{

src/testdir/test_ins_complete.vim

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2344,15 +2344,16 @@ func Test_complete_info_index()
23442344
call feedkeys("Go\<C-X>\<C-P>\<F5>\<Esc>_dd", 'tx')
23452345
call assert_equal(-1, g:compl_info['selected'])
23462346

2347-
" Check if index out of range
2348-
" https://github.com/vim/vim/pull/12971
23492347
call feedkeys("Go\<C-X>\<C-N>\<C-P>\<F5>\<Esc>_dd", 'tx')
23502348
call assert_equal(0, g:compl_info['selected'])
23512349
call assert_equal(6 , len(g:compl_info['items']))
23522350
call assert_equal("fff", g:compl_info['items'][g:compl_info['selected']]['word'])
23532351
call feedkeys("Go\<C-X>\<C-N>\<C-N>\<C-N>\<C-N>\<C-N>\<C-N>\<C-N>\<C-N>\<C-N>\<F5>\<Esc>_dd", 'tx')
23542352
call assert_equal("aaa", g:compl_info['items'][g:compl_info['selected']]['word'])
23552353
call assert_equal(6 , len(g:compl_info['items']))
2354+
call feedkeys("Go\<C-X>\<C-N>\<F5>\<Esc>_dd", 'tx')
2355+
call assert_equal(-1, g:compl_info['selected'])
2356+
call assert_equal(6 , len(g:compl_info['items']))
23562357

23572358
set completeopt&
23582359
bwipe!

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
2090,
707709
/**/
708710
2089,
709711
/**/

0 commit comments

Comments
 (0)