Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit19d5b28

Browse files
zeertzjqgirishji
andauthored
vim-patch:9.1.1931: completion: wrong item selected with fuzzy and noinsert (#36725)
Problem: completion: wrong item selected with fuzzy and noinsert (Evgeni Chasnovski)Solution: Reset selected item after fuzzy sort (Girish Palya)fixes:vim/vim#18802closes:vim/vim#18816vim/vim@057ea12Co-authored-by: Girish Palya <girishji@gmail.com>
1 parenta4e867c commit19d5b28

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

‎src/nvim/insexpand.c‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2247,16 +2247,17 @@ static void ins_compl_fuzzy_sort(void)
22472247
{
22482248
unsignedcur_cot_flags=get_cot_flags();
22492249

2250-
//set the fuzzy score in cp_score
2250+
//Set the fuzzy score in cp_score and sort
22512251
set_fuzzy_score();
2252-
// Sort the matches linked list based on fuzzy score
22532252
if (!(cur_cot_flags&kOptCotFlagNosort)) {
22542253
sort_compl_match_list(cp_compare_fuzzy);
2255-
if ((cur_cot_flags& (kOptCotFlagNoinsert|kOptCotFlagNoselect))==kOptCotFlagNoinsert
2256-
&&compl_first_match) {
2257-
compl_shown_match=compl_first_match;
2258-
if (compl_shows_dir_forward()&& !compl_autocomplete) {
2259-
compl_shown_match=compl_first_match->cp_next;
2254+
// Reset the shown item since sorting reorders items
2255+
if ((cur_cot_flags& (kOptCotFlagNoinsert|kOptCotFlagNoselect))==kOptCotFlagNoinsert) {
2256+
boolnone_selected=compl_shown_match== (compl_shows_dir_forward()
2257+
?compl_first_match :compl_first_match->cp_prev);
2258+
if (!none_selected) {
2259+
compl_shown_match= (!compl_autocomplete&&compl_shows_dir_forward())
2260+
?compl_first_match->cp_next :compl_first_match;
22602261
}
22612262
}
22622263
}

‎test/old/testdir/test_ins_complete.vim‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3703,6 +3703,15 @@ func Test_complete_opt_fuzzy()
37033703
callfeedkeys("Gof\<C-N>\<C-R>=PrintMenuWords()\<CR>\<Esc>0",'tx')
37043704
callassert_equal('f{''items'': [''func1'',''func2'',''xfunc'']}',getline('.'))
37053705

3706+
" Issue #18802: Reset selected item after fuzzy sort
3707+
%d
3708+
callsetline(1, ['aa','aaa','aaaa'])
3709+
setcompleteopt=menuone,noinsert,fuzzy
3710+
callfeedkeys("Goa\<C-N>\<C-Y>\<Esc>",'tx')
3711+
callassert_equal('aa',getline('.'))
3712+
callfeedkeys("Goa\<C-P>\<C-Y>\<Esc>",'tx')
3713+
callassert_equal('aaaa',getline('.'))
3714+
37063715
" clean up
37073716
setomnifunc=
37083717
bw!

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp