diff --git a/java/java-tests/testSrc/com/intellij/psi/codeStyle/autodetect/DetectIndentAndTypeTest.java b/java/java-tests/testSrc/com/intellij/psi/codeStyle/autodetect/DetectIndentAndTypeTest.java index adbf48df086b..0a13972a6be4 100644 --- a/java/java-tests/testSrc/com/intellij/psi/codeStyle/autodetect/DetectIndentAndTypeTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/codeStyle/autodetect/DetectIndentAndTypeTest.java @@ -71,4 +71,29 @@ public class DetectIndentAndTypeTest extends LightPlatformCodeInsightFixtureTest "\t}\n" + "}\n"); } + + public void testWhenTabsDetected_SetContinuationIndentSizeToDoubleTabSize() { + CommonCodeStyleSettings common = mySettings.getCommonSettings(JavaLanguage.INSTANCE); + CommonCodeStyleSettings.IndentOptions indentOptions = common.getIndentOptions(); + + assert indentOptions != null; + + indentOptions.INDENT_SIZE = 1; + indentOptions.TAB_SIZE = 2; + indentOptions.CONTINUATION_INDENT_SIZE = 8; + + myFixture.configureByText(JavaFileType.INSTANCE, + "public class T {\n" + + "\tvoid run() {\n" + + "\t\tint a = 2 + 2;\n" + + "\t}\n" + + "}\n"); + myFixture.type('\n'); + myFixture.checkResult("public class T {\n" + + "\tvoid run() {\n" + + "\t\tint a = 2 \n" + + "\t\t\t\t+ 2;\n" + + "\t}\n" + + "}\n"); + } } diff --git a/platform/lang-impl/src/com/intellij/psi/codeStyle/autodetect/IndentOptionsDetectorImpl.java b/platform/lang-impl/src/com/intellij/psi/codeStyle/autodetect/IndentOptionsDetectorImpl.java index 4c425a8e4d24..3fa3b3bd785e 100644 --- a/platform/lang-impl/src/com/intellij/psi/codeStyle/autodetect/IndentOptionsDetectorImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/codeStyle/autodetect/IndentOptionsDetectorImpl.java @@ -82,6 +82,7 @@ public class IndentOptionsDetectorImpl implements IndentOptionsDetector { if (linesWithTabs > linesWithWhiteSpaceIndent) { setUseTabs(indentOptions, true); indentOptions.INDENT_SIZE = indentOptions.TAB_SIZE; + indentOptions.CONTINUATION_INDENT_SIZE = indentOptions.TAB_SIZE * 2; } else if (linesWithWhiteSpaceIndent > linesWithTabs) { setUseTabs(indentOptions, false);