diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c index 6e57c0bf66..1b245e23be 100644 --- a/src/nvim/insexpand.c +++ b/src/nvim/insexpand.c @@ -3944,7 +3944,7 @@ static compl_T *find_comp_when_fuzzy(void) if ((is_forward && compl_selected_item == compl_match_arraysize - 1) || (is_backward && compl_selected_item == 0)) { return compl_first_match != compl_shown_match - ? compl_first_match + ? (is_forward ? compl_shown_match->cp_next : compl_first_match) : (compl_first_match->cp_prev ? compl_first_match->cp_prev : NULL); } diff --git a/test/old/testdir/test_ins_complete.vim b/test/old/testdir/test_ins_complete.vim index b37eca4ac6..526ac9f7f4 100644 --- a/test/old/testdir/test_ins_complete.vim +++ b/test/old/testdir/test_ins_complete.vim @@ -2886,6 +2886,8 @@ func Test_complete_fuzzy_match() call assert_equal('bar', getline('.')) call feedkeys("Sb\\\\", 'tx') call assert_equal('blue', getline('.')) + call feedkeys("Sb\\\\\", 'tx') + call assert_equal('b', getline('.')) " clean up set omnifunc=