Fix auto-indent for {

This commit is contained in:
Nikolay Krasko
2013-11-16 20:33:49 -08:00
committed by Nikolay Krasko
parent 99ddfe8c83
commit 9ed900e2be
2 changed files with 25 additions and 1 deletions
@@ -76,8 +76,8 @@ public class KotlinTypedHandler extends TypedHandlerDelegate {
if (previousElement instanceof LeafPsiElement
&& ((LeafPsiElement) previousElement).getElementType() == JetTokens.LONG_TEMPLATE_ENTRY_START) {
editor.getDocument().insertString(offset, "}");
return Result.STOP;
}
return Result.STOP;
}
return Result.CONTINUE;
@@ -26,6 +26,30 @@ public class TypedHandlerTest extends LightCodeInsightTestCase {
checkResultByText("val x = \"${}\"");
}
public void testAutoIndentRightOpenBrace() throws Exception {
configureFromFileText("a.kt",
"fun test() {\n" +
"<caret>\n" +
"}");
EditorTestUtil.performTypingAction(getEditor(), '{');
checkResultByText(
"fun test() {\n" +
" {<caret>}\n" +
"}");
}
public void testAutoIndentLeftOpenBrace() throws Exception {
configureFromFileText("a.kt",
"fun test() {\n" +
" <caret>\n" +
"}");
EditorTestUtil.performTypingAction(getEditor(), '{');
checkResultByText(
"fun test() {\n" +
" {<caret>}\n" +
"}");
}
public void testTypeStringTemplateStartWithCloseBraceAfter() throws Exception {
configureFromFileText("a.kt", "fun foo() { \"$<caret>\" }");
EditorTestUtil.performTypingAction(getEditor(), '{');