summaryrefslogtreecommitdiffstats
path: root/lib/Format/UnwrappedLineFormatter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Format/UnwrappedLineFormatter.cpp')
-rw-r--r--lib/Format/UnwrappedLineFormatter.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/Format/UnwrappedLineFormatter.cpp b/lib/Format/UnwrappedLineFormatter.cpp
index 906dae40cb..7e1d805a5f 100644
--- a/lib/Format/UnwrappedLineFormatter.cpp
+++ b/lib/Format/UnwrappedLineFormatter.cpp
@@ -672,7 +672,7 @@ public:
LineFormatter(ContinuationIndenter *Indenter, WhitespaceManager *Whitespaces,
const FormatStyle &Style,
UnwrappedLineFormatter *BlockFormatter)
- : Indenter(Indenter), Whitespaces(Whitespaces), Style(Style),
+ : Indenter(Indenter), Style(Style), Whitespaces(Whitespaces),
BlockFormatter(BlockFormatter) {}
virtual ~LineFormatter() {}
@@ -760,10 +760,10 @@ protected:
}
ContinuationIndenter *Indenter;
+ const FormatStyle &Style;
private:
WhitespaceManager *Whitespaces;
- const FormatStyle &Style;
UnwrappedLineFormatter *BlockFormatter;
};
@@ -786,7 +786,8 @@ public:
while (State.NextToken) {
bool Newline =
Indenter->mustBreak(State) ||
- (Indenter->canBreak(State) && State.NextToken->NewlinesBefore > 0);
+ (State.NextToken->NewlinesBefore > 0 &&
+ (Style.KeepLineBreaksForNonEmptyLines || Indenter->canBreak(State)));
unsigned Penalty = 0;
formatChildren(State, Newline, /*DryRun=*/false, Penalty);
Indenter->addTokenToState(State, Newline, /*DryRun=*/false);