diff --git a/idea/src/org/jetbrains/jet/plugin/completion/handlers/JetFunctionInsertHandler.kt b/idea/src/org/jetbrains/jet/plugin/completion/handlers/JetFunctionInsertHandler.kt index 33e640034a3..5f4bf599e61 100644 --- a/idea/src/org/jetbrains/jet/plugin/completion/handlers/JetFunctionInsertHandler.kt +++ b/idea/src/org/jetbrains/jet/plugin/completion/handlers/JetFunctionInsertHandler.kt @@ -77,12 +77,15 @@ public class JetFunctionInsertHandler(val caretPosition : CaretPosition, val bra val document = context.getDocument() val completionChar = context.getCompletionChar() - val braces = bracketType == BracketType.BRACES && completionChar != '(' + var documentText = document.getText() + + val forceParenthesis = bracketType == BracketType.BRACES && completionChar == '\t' && documentText.charAt(offset) == '(' + + val braces = bracketType == BracketType.BRACES && completionChar != '(' && !forceParenthesis val openingBracket = if (braces) '{' else '(' val closingBracket = if (braces) '}' else ')' - var documentText = document.getText() var openingBracketIndex = indexOfSkippingSpace(documentText, openingBracket, offset) var inBracketsShift = 0 if (openingBracketIndex == -1) { diff --git a/idea/testData/completion/handlers/ForceParenthesisForTabChar.kt b/idea/testData/completion/handlers/ForceParenthesisForTabChar.kt new file mode 100644 index 00000000000..1320a4b0fe7 --- /dev/null +++ b/idea/testData/completion/handlers/ForceParenthesisForTabChar.kt @@ -0,0 +1,8 @@ +package testing + +fun some(f: () -> Unit) = 12 +fun other() = 12 + +fun test() { + somother() +} diff --git a/idea/testData/completion/handlers/ForceParenthesisForTabChar.kt.after b/idea/testData/completion/handlers/ForceParenthesisForTabChar.kt.after new file mode 100644 index 00000000000..2bbaada051e --- /dev/null +++ b/idea/testData/completion/handlers/ForceParenthesisForTabChar.kt.after @@ -0,0 +1,8 @@ +package testing + +fun some(f: () -> Unit) = 12 +fun other() = 12 + +fun test() { + some() +} diff --git a/idea/tests/org/jetbrains/jet/completion/handlers/CompletionHandlerTest.kt b/idea/tests/org/jetbrains/jet/completion/handlers/CompletionHandlerTest.kt index 85e7963659e..2e2585068ad 100644 --- a/idea/tests/org/jetbrains/jet/completion/handlers/CompletionHandlerTest.kt +++ b/idea/tests/org/jetbrains/jet/completion/handlers/CompletionHandlerTest.kt @@ -30,8 +30,8 @@ import com.intellij.codeInsight.lookup.LookupManager import com.intellij.codeInsight.lookup.LookupElementPresentation import org.junit.Assert import com.intellij.openapi.application.Result -import kotlin.properties.Delegates import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture +import kotlin.properties.Delegates public class CompletionHandlerTest() : JetLightCodeInsightFixtureTestCase() { fun testClassCompletionImport() = doTest(CompletionType.BASIC, 2, "SortedSet", null, '\n') @@ -68,6 +68,8 @@ public class CompletionHandlerTest() : JetLightCodeInsightFixtureTestCase() { fun testHigherOrderFunctionWithArg() = doTest(CompletionType.BASIC, 2, "filterNot", null, '\n') + fun testForceParenthesisForTabChar() = doTest(CompletionType.BASIC, 0, "some", null, '\t') + var fixture by Delegates.notNull() protected override fun setUp() {