When detecting tab usage set continuation indent size to doubled tab size (IDEA-141219)

This commit is contained in:
Yaroslav Lepenkin
2015-06-18 12:40:53 +03:00
parent d49c944236
commit f08fcea334
2 changed files with 26 additions and 0 deletions
@@ -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 <caret>+ 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<caret>+ 2;\n" +
"\t}\n" +
"}\n");
}
}
@@ -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);