Do not insert closing brace for string template between open brace and identifier (KT-11143)
#KT-11143 Fixed
This commit is contained in:
committed by
Nikolay Krasko
parent
44926df47e
commit
30c2b26339
@@ -250,8 +250,13 @@ public class KotlinTypedHandler extends TypedHandlerDelegate {
|
||||
PsiElement previousElement = file.findElementAt(offset - 1);
|
||||
if (previousElement instanceof LeafPsiElement
|
||||
&& ((LeafPsiElement) previousElement).getElementType() == KtTokens.LONG_TEMPLATE_ENTRY_START) {
|
||||
editor.getDocument().insertString(offset, "}");
|
||||
return Result.STOP;
|
||||
PsiElement currentElement = file.findElementAt(offset);
|
||||
|
||||
if (currentElement instanceof LeafPsiElement
|
||||
&& ((LeafPsiElement) currentElement).getElementType() != KtTokens.IDENTIFIER) {
|
||||
editor.getDocument().insertString(offset, "}");
|
||||
return Result.STOP;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (c == ':') {
|
||||
|
||||
@@ -65,7 +65,7 @@ class TypedHandlerTest : LightCodeInsightTestCase() {
|
||||
fun testTypeStringTemplateStartBeforeString() = doCharTypeTest(
|
||||
'{',
|
||||
"""fun foo() { "$<caret>something" }""",
|
||||
"""fun foo() { "$dollar{}something" }"""
|
||||
"""fun foo() { "$dollar{something" }"""
|
||||
)
|
||||
|
||||
fun testKT3575() = doCharTypeTest(
|
||||
|
||||
Reference in New Issue
Block a user