[command-completion] IDEA-375804 Impossible to find CommandCompletionType

(cherry picked from commit 168553d5b5bce830d4a231115f4c5b734eacf788)

IJ-CR-168918

GitOrigin-RevId: aa56e2e8ebd4e84438e64f8a24528c3385b8c17a
This commit is contained in:
Mikhail Pyltsin
2025-07-11 13:47:08 +02:00
committed by intellij-monorepo-bot
parent 9f571ef662
commit a8d0a77229
2 changed files with 11 additions and 1 deletions

View File

@@ -962,6 +962,16 @@ class JavaCommandsCompletionTest : LightFixtureCompletionTestCase() {
assertTrue(elements.any { element -> element.lookupString.contains("Create method from", ignoreCase = true) })
}
fun testForceCallException() {
Registry.get("ide.completion.command.force.enabled").setValue(true, getTestRootDisposable())
myFixture.configureByText(JavaFileType.INSTANCE, """
class A {
void foo() {
}
}
a<caret>""".trimIndent())
myFixture.completeBasic()
}
private class TestHintManager : HintManagerImpl() {
var called: Boolean = false

View File

@@ -429,7 +429,7 @@ internal fun findCommandCompletionType(
return InvocationCommandType.FullSuffix(text.substring(offset - indexOf + 2, offset),
text.substring(offset - indexOf, offset - indexOf + 2))
}
if (indexOf > 0 && text.substring(offset - indexOf, offset - indexOf + 2).startsWith(factory.suffix())) {
if (indexOf > 0 && text.substring(offset - indexOf).startsWith(factory.suffix())) {
//force call with one point
return InvocationCommandType.PartialSuffix(text.substring(offset - indexOf + 1, offset),
text.substring(offset - indexOf, offset - indexOf + 1))