diff --git a/plugins/kotlin/code-insight/intentions-shared/resources/kotlin.code-insight.intentions.shared.xml b/plugins/kotlin/code-insight/intentions-shared/resources/kotlin.code-insight.intentions.shared.xml index cd3e2e160bc6..86a6c9292ed3 100644 --- a/plugins/kotlin/code-insight/intentions-shared/resources/kotlin.code-insight.intentions.shared.xml +++ b/plugins/kotlin/code-insight/intentions-shared/resources/kotlin.code-insight.intentions.shared.xml @@ -440,5 +440,9 @@ messages.KotlinBundle group.names.kotlin + + \ No newline at end of file diff --git a/plugins/kotlin/code-insight/intentions-shared/src/org/jetbrains/kotlin/idea/codeInsight/intentions/shared/KotlinIntentionCommandSkipper.kt b/plugins/kotlin/code-insight/intentions-shared/src/org/jetbrains/kotlin/idea/codeInsight/intentions/shared/KotlinIntentionCommandSkipper.kt new file mode 100644 index 000000000000..d445f3915ce8 --- /dev/null +++ b/plugins/kotlin/code-insight/intentions-shared/src/org/jetbrains/kotlin/idea/codeInsight/intentions/shared/KotlinIntentionCommandSkipper.kt @@ -0,0 +1,16 @@ +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package org.jetbrains.kotlin.idea.codeInsight.intentions.shared + +import com.intellij.codeInsight.completion.command.commands.IntentionCommandSkipper +import com.intellij.codeInsight.intention.CommonIntentionAction +import com.intellij.codeInsight.intention.IntentionAction +import com.intellij.codeInsight.intention.IntentionActionDelegate +import com.intellij.psi.PsiFile + +class KotlinIntentionCommandSkipper : IntentionCommandSkipper { + override fun skip(action: CommonIntentionAction, psiFile: PsiFile, offset: Int): Boolean { + if (action !is IntentionAction) return false + val unwrappedIntentionAction = IntentionActionDelegate.unwrap(action) + return unwrappedIntentionAction is IntroduceVariableIntention + } +} \ No newline at end of file diff --git a/plugins/kotlin/fir/tests/test/org/jetbrains/kotlin/idea/fir/completion/commands/K2CommandCompletionTest.kt b/plugins/kotlin/fir/tests/test/org/jetbrains/kotlin/idea/fir/completion/commands/K2CommandCompletionTest.kt index a7341f01088d..e6ba6fbd5c09 100644 --- a/plugins/kotlin/fir/tests/test/org/jetbrains/kotlin/idea/fir/completion/commands/K2CommandCompletionTest.kt +++ b/plugins/kotlin/fir/tests/test/org/jetbrains/kotlin/idea/fir/completion/commands/K2CommandCompletionTest.kt @@ -594,6 +594,7 @@ class K2CommandCompletionTest : KotlinLightCodeInsightFixtureTestCase() { ) val elements = myFixture.completeBasic() + assertNull(elements.firstOrNull { element -> element.lookupString.contains("Introduce local variable", ignoreCase = true) }) selectItem(elements.first { element -> element.lookupString.contains("Introduce variable", ignoreCase = true) }) NonBlockingReadActionImpl.waitForAsyncTaskCompletion()