From 28b099ec22c078fe4564e61b72befb96806e607f Mon Sep 17 00:00:00 2001 From: Frederik Haselmeier Date: Thu, 8 Jan 2026 12:43:17 +0100 Subject: [PATCH] [kotlin] KTIJ-36825 use auto-popup after moving caret inside lambda rather than invoking completion explicitly ^KTIJ-36825 fixed GitOrigin-RevId: 65e502bce933774c4ba48f9205497a9c19ed54bd --- .../factories/FunctionLookupElementFactory.kt | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/plugins/kotlin/completion/impl-k2/src/org/jetbrains/kotlin/idea/completion/lookups/factories/FunctionLookupElementFactory.kt b/plugins/kotlin/completion/impl-k2/src/org/jetbrains/kotlin/idea/completion/lookups/factories/FunctionLookupElementFactory.kt index 2559d6cd295f..d7d8a8145d6f 100644 --- a/plugins/kotlin/completion/impl-k2/src/org/jetbrains/kotlin/idea/completion/lookups/factories/FunctionLookupElementFactory.kt +++ b/plugins/kotlin/completion/impl-k2/src/org/jetbrains/kotlin/idea/completion/lookups/factories/FunctionLookupElementFactory.kt @@ -3,8 +3,6 @@ package org.jetbrains.kotlin.idea.completion.lookups.factories import com.intellij.codeInsight.AutoPopupController -import com.intellij.codeInsight.completion.CodeCompletionHandlerBase -import com.intellij.codeInsight.completion.CompletionType import com.intellij.codeInsight.completion.InsertionContext import com.intellij.codeInsight.lookup.Lookup import com.intellij.codeInsight.lookup.LookupElement @@ -405,12 +403,12 @@ internal object FunctionInsertionHandler : QuotedNamesAwareInsertionHandler() { } context.laterRunnable = if (insertLambda) Runnable { - CodeCompletionHandlerBase( - /* completionType = */ CompletionType.BASIC, - /* invokedExplicitly = */ false, - /* autopopup = */ true, - /* synchronous = */ false, - ).invokeCompletion(project, editor) + // We schedule auto-popup after moving the caret into the lambda. + // It needs to be auto-popup rather than invoking completion manually, + // otherwise pressing space will cause completion to insert the item, which is + // not always wanted, see: KTIJ-36825 + AutoPopupController.getInstance(project) + .scheduleAutoPopup(editor) } else Runnable { AutoPopupController.getInstance(project) .autoPopupParameterInfo(editor, offsetElement)