join lines do not merge closing brace and catch keyword, when 'catch on new line' enabled (IDEA-179581)

This commit is contained in:
Yaroslav Lepenkin
2017-10-17 10:21:10 +03:00
parent e4efb836cd
commit c6d8b2f05e
4 changed files with 26 additions and 1 deletions
@@ -712,7 +712,7 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
private void processOnNewLineCondition(boolean onNewLine, boolean createSpaceInline) {
if (onNewLine) {
if (!mySettings.KEEP_SIMPLE_BLOCKS_IN_ONE_LINE) {
myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
myResult = Spacing.createSpacing(1, 1, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
else {
myResult = Spacing.createDependentLFSpacing(0, 1, myParent.getTextRange(), mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
@@ -0,0 +1,10 @@
class A {
public void foo() {
try {
System.out.println("Hello");
}<caret>
catch (Exception e) {
System.err.println("Error");
}
}
}
@@ -0,0 +1,9 @@
class A {
public void foo() {
try {
System.out.println("Hello");
} catch (Exception e) {
System.err.println("Error");
}
}
}
@@ -231,6 +231,12 @@ public class JoinLinesTest extends LightCodeInsightTestCase {
public void testMultipleBlockComments() { doTest(); }
public void testPreserveSpaceIfOnNewLineOptionEnabled() {
CommonCodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject()).getCommonSettings(JavaLanguage.INSTANCE);
settings.CATCH_ON_NEW_LINE = true;
doTest();
}
private void doTest() {
doTest(".java");
}