diff options
Diffstat (limited to 'java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java')
-rw-r--r-- | java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java b/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java index e81e167d3c45..1376f44c07ca 100644 --- a/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java +++ b/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java @@ -296,7 +296,12 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor { } else if (myRole1 == ChildRole.FIELD) { int lines = Math.max(getLinesAroundField(), getLinesAroundMethod()) + 1; - myResult = Spacing.createSpacing(0, mySettings.SPACE_BEFORE_CLASS_LBRACE ? 1 : 0, 0, true, mySettings.KEEP_BLANK_LINES_BEFORE_RBRACE, + // IJ has been keeping initialization block which starts at the same line as a field for a while. + // However, it's not convenient for a situation when particular code is created via PSI - it's easier to not bothering + // with whitespace elements when inserting, say, new initialization blocks. That's why we don't enforce new line + // only during explicit reformatting ('Reformat' action). + int minLineFeeds = FormatterUtil.isFormatterCalledExplicitly() ? 0 : 1; + myResult = Spacing.createSpacing(0, mySettings.SPACE_BEFORE_CLASS_LBRACE ? 1 : 0, 1, true, mySettings.KEEP_BLANK_LINES_BEFORE_RBRACE, lines); } else if (myRole1 == ChildRole.CLASS) { |