Skip to content

Commit

Permalink
fix(completion): stop completion when completion is exhausted
Browse files Browse the repository at this point in the history
Problem: Currently, completion is not stopped when completion is exhausted (no matching completion items), which also means `CompleteDone` is not called either. Furthermore, `CompleteDone` is called when pressing a special character (Backspace, Space, Esc) instead.

Solution: Correctly stop completion and trigger `CompleteDone` when completion is exhausted.
  • Loading branch information
famiu committed Apr 28, 2024
1 parent 6106365 commit 0b9b14e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/nvim/insexpand.c
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,7 @@ static int ins_compl_build_pum(void)
/// Also adjusts "compl_shown_match" to an entry that is actually displayed.
void ins_compl_show_pum(void)
{
if (!pum_wanted() || !pum_enough_matches()) {
if (!pum_wanted()) {
return;
}

Expand All @@ -1278,10 +1278,15 @@ void ins_compl_show_pum(void)
}
}

if (compl_match_array == NULL) {
if (compl_match_array == NULL || !pum_enough_matches()) {
if (compl_started && has_event(EVENT_COMPLETECHANGED)) {
trigger_complete_changed_event(cur);
}
}

// Stop completion when completion is exhausted
if (compl_match_array == NULL && ctrl_x_mode_not_default()) {
ins_compl_prep(' ');
return;
}

Expand Down

0 comments on commit 0b9b14e

Please sign in to comment.