summaryrefslogtreecommitdiffstats
path: root/lib/Format/FormatToken.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-08-27 08:43:47 +0000
committerDaniel Jasper <djasper@google.com>2013-08-27 08:43:47 +0000
commit451f1e0e5040db6a114217e7bd9767bf751d5bd3 (patch)
treefdd26db41b0ce444830488c9237f94f7714850c0 /lib/Format/FormatToken.cpp
parent309f6456626fdc85181fd42d9ed8d9c0c5a6746a (diff)
clang-format: Fix bug in column layout.
Before (with 60 character limit in Google style): return { {aaaaaaaaaaaaaaaaaaaaaaaaa}, {aaaaaaaaaaaaaaaaa}, {aaaaaaaaaaaaaaaaaaaaaaaaa}, {aaaaaaaaaaaaaaaaa}}; After: return {{aaaaaaaaaaaaaaaaaaaaaaaaa}, {aaaaaaaaaaaaaaaaa}, {aaaaaaaaaaaaaaaaaaaaaaaaa}, {aaaaaaaaaaaaaaaaa}}; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189327 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/FormatToken.cpp')
-rw-r--r--lib/Format/FormatToken.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Format/FormatToken.cpp b/lib/Format/FormatToken.cpp
index 24a296adc2..e6c72ab0de 100644
--- a/lib/Format/FormatToken.cpp
+++ b/lib/Format/FormatToken.cpp
@@ -39,9 +39,13 @@ unsigned CommaSeparatedList::format(LineState &State,
LBrace->Next->Type == TT_DesignatedInitializerPeriod)
return 0;
+ // Calculate the number of code points we have to format this list. As the
+ // first token is already placed, we have to subtract it.
+ unsigned RemainingCodePoints = Style.ColumnLimit - State.Column +
+ State.NextToken->Previous->CodePointCount;
+
// Find the best ColumnFormat, i.e. the best number of columns to use.
- unsigned RemainingCharacters = Style.ColumnLimit - State.Stack.back().Indent;
- const ColumnFormat *Format = getColumnFormat(RemainingCharacters);
+ const ColumnFormat *Format = getColumnFormat(RemainingCodePoints);
if (!Format)
return 0;