[command-completion] IDEA-385364 Generation doesn't work on a new line with tabs

GitOrigin-RevId: 36a9526f790baae02f68afdc7e7bbfe5bde75217
This commit is contained in:
Mikhail Pyltsin
2026-02-02 14:22:38 +00:00
committed by intellij-monorepo-bot
parent 5cc59f26f8
commit 3ffc1737dc
2 changed files with 29 additions and 1 deletions
@@ -8,7 +8,7 @@ import com.intellij.openapi.util.registry.Registry
import com.intellij.testFramework.NeedsIndex
@NeedsIndex.SmartMode(reason = "it requires highlighting")
class JavaCommandsCompletionGenerateConstructorsTest : LightFixtureCompletionTestCase() {
class JavaCommandsCompletionGenerateTest : LightFixtureCompletionTestCase() {
override fun setUp() {
super.setUp()
@@ -16,6 +16,33 @@ class JavaCommandsCompletionGenerateConstructorsTest : LightFixtureCompletionTes
Registry.get("ide.completion.command.force.enabled").setValue(true, getTestRootDisposable())
}
fun testGenerateWithTabs() {
//don't move, there are tabs instead of spaces
val text = """
package org.test;
public class Test {
private Integer num;
ge<caret>
}""".trimIndent()
myFixture.configureByText(JavaFileType.INSTANCE, text)
val elements = myFixture.completeBasic()
selectItem(elements.first { element -> element.lookupString.contains("Generate 'No-Args Constructor'", ignoreCase = true) })
NonBlockingReadActionImpl.waitForAsyncTaskCompletion()
myFixture.checkResult("""
package org.test;
public class Test {
private Integer num;
public Test() {
}
}""".trimIndent())
}
fun testGenerateNoArgsConstructor() {
myFixture.configureByText(JavaFileType.INSTANCE, """
class A {
@@ -614,6 +614,7 @@ internal fun findActualIndex(suffix: String, text: CharSequence, offset: Int): I
var currentIndex = 1
while (text.getOrNull(offset - currentIndex)?.isLetter() == true ||
text.getOrNull(offset - currentIndex) == ' ' ||
text.getOrNull(offset - currentIndex) == '\t' ||
text.getOrNull(offset - currentIndex) == '\''
) {
currentIndex++