diff options
-rw-r--r-- | src/nvim/insexpand.c | 8 | ||||
-rw-r--r-- | test/old/testdir/test_ins_complete.vim | 10 |
2 files changed, 14 insertions, 4 deletions
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c index 1eb6402e6c..0a25b72451 100644 --- a/src/nvim/insexpand.c +++ b/src/nvim/insexpand.c @@ -3698,16 +3698,16 @@ static int find_next_completion_match(bool allow_get_expansion, int todo, bool a while (--todo >= 0) { if (compl_shows_dir_forward() && compl_shown_match->cp_next != NULL) { - compl_shown_match = !compl_fuzzy_match ? compl_shown_match->cp_next - : find_comp_when_fuzzy(); + compl_shown_match = compl_fuzzy_match && compl_match_array != NULL + ? find_comp_when_fuzzy() : compl_shown_match->cp_next; found_end = (compl_first_match != NULL && (is_first_match(compl_shown_match->cp_next) || is_first_match(compl_shown_match))); } else if (compl_shows_dir_backward() && compl_shown_match->cp_prev != NULL) { found_end = is_first_match(compl_shown_match); - compl_shown_match = !compl_fuzzy_match ? compl_shown_match->cp_prev - : find_comp_when_fuzzy(); + compl_shown_match = compl_fuzzy_match && compl_match_array != NULL + ? find_comp_when_fuzzy() : compl_shown_match->cp_prev; found_end |= is_first_match(compl_shown_match); } else { if (!allow_get_expansion) { diff --git a/test/old/testdir/test_ins_complete.vim b/test/old/testdir/test_ins_complete.vim index f8fed8d16c..96e37bd673 100644 --- a/test/old/testdir/test_ins_complete.vim +++ b/test/old/testdir/test_ins_complete.vim @@ -2634,6 +2634,16 @@ func Test_complete_fuzzy_match() call feedkeys("S\<C-x>\<C-o>fb\<C-n>", 'tx') call assert_equal('fooBaz', g:word) + " avoid break default completion behavior + set completeopt=fuzzy,menu + call setline(1, ['hello help hero h']) + exe "norm! A\<C-X>\<C-N>" + call assert_equal('hello help hero hello', getline('.')) + set completeopt+=noinsert + call setline(1, ['hello help hero h']) + exe "norm! A\<C-X>\<C-N>" + call assert_equal('hello help hero h', getline('.')) + " clean up set omnifunc= bw! |