Skip to content

Commit

Permalink
Minor enhancement to the earlier LSP code completion enhancement such…
Browse files Browse the repository at this point in the history
… that word completions are not shown on auto-completion or odd completion trigger counts. This means that pressing Ctrl+Space repeatedly will now toggle word completions on and off but they won't be shown when there are LSP-based completions on auto-complete or initial explicit completion trigger.
  • Loading branch information
SCWells72 authored and angelozerr committed Dec 11, 2024
1 parent 5157bd2 commit f87d49b
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,13 @@ private void addCompletionItems(@NotNull CompletionParameters parameters,
}
}

// If completions were added from LSP and this is auto-completion or the explicit completion trigger was typed
// only once, add completions from other all other contributors except for the word completion contributor.
// If completions were added from LSP and this is auto-completion or the explicit completion was triggered an
// odd number of times (acts as a toggle), add completions from other all other contributors except for the
// word completion contributor.
// Note that the word completion contributor only really kicks in when LSP completions are added in the context
// of a TextMate file (see TextMateCompletionContributor), but that's going to be very common for LSP usage
// since it's often adding (pseudo-)language support when not already present in the host JetBrains IDE.
if ((size > 0) && (parameters.getInvocationCount() < 2)) {
if ((size > 0) && ((parameters.getInvocationCount() == 0) || ((parameters.getInvocationCount() % 2) > 0))) {
// Don't allow automatic execution of the remaining completion contributors; we'll execute them ourselves below
result.stopHere();

Expand Down

0 comments on commit f87d49b

Please sign in to comment.