aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Format/Format.cpp2
-rw-r--r--unittests/Format/FormatTest.cpp6
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp
index 00ec79f5e4..7687aa347b 100644
--- a/lib/Format/Format.cpp
+++ b/lib/Format/Format.cpp
@@ -727,7 +727,7 @@ private:
TailOffset += SplitPoint + 1;
TailLength -= SplitPoint + 1;
OffsetFromStart = 1;
- Penalty += 100;
+ Penalty += Style.PenaltyExcessCharacter;
}
State.Column = StartColumn + TailLength;
return Penalty;
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 17dae0ffe6..a902466c4c 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -2984,6 +2984,12 @@ TEST_F(FormatTest, BreakStringLiterals) {
" \"text\",\n"
" other);",
format("f(\"some text\", other);", getLLVMStyleWithColumns(10)));
+
+ // Only break as a last resort.
+ verifyFormat(
+ "aaaaaaaaaaaaaaaaaaaa(\n"
+ " aaaaaaaaaaaaaaaaaaaa,\n"
+ " aaaaaa(\"aaa aaaaa aaa aaa aaaaa aaa aaaaa aaa aaa aaaaaa\"));");
}
} // end namespace tooling