From f87d49bb8bd134c70523aa29b2fc00c62f5946d7 Mon Sep 17 00:00:00 2001 From: Scott Wells Date: Wed, 11 Dec 2024 15:10:31 -0600 Subject: [PATCH] Minor enhancement to the earlier LSP code completion enhancement such 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. --- .../features/completion/LSPCompletionContributor.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/redhat/devtools/lsp4ij/features/completion/LSPCompletionContributor.java b/src/main/java/com/redhat/devtools/lsp4ij/features/completion/LSPCompletionContributor.java index 4787fd3b2..3b34f462e 100644 --- a/src/main/java/com/redhat/devtools/lsp4ij/features/completion/LSPCompletionContributor.java +++ b/src/main/java/com/redhat/devtools/lsp4ij/features/completion/LSPCompletionContributor.java @@ -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();