clang-format: Improve column layout.
authorDaniel Jasper <djasper@google.com>
Mon, 11 May 2015 13:35:40 +0000 (13:35 +0000)
committerDaniel Jasper <djasper@google.com>
Mon, 11 May 2015 13:35:40 +0000 (13:35 +0000)
commitd57843d4e3f1646ddc3c057b6d8daf6c97978aab
tree8b7b5f4da8bcfbc2fa7b42f2c8ed203d8aa77598
parentff82fce1c09d27f5d11bed76f44eb14d9d764180
clang-format: Improve column layout.

Specifically, calculate the deviation between the shortest and longest
element (which is used to prevent excessive whitespace) per column, not
overall. This automatically handles the corner cases of a single column
and a single row so that the actualy implementation becomes simpler.

Before:
  vector<int> x = {1,
                   aaaaaaaaaaaaaaaaaaaaaa,
                   2,
                   bbbbbbbbbbbbbbbbbbbbbb,
                   3,
                   cccccccccccccccccccccc};

After:
  vector<int> x = {1, aaaaaaaaaaaaaaaaaaaaaa,
                   2, bbbbbbbbbbbbbbbbbbbbbb,
                   3, cccccccccccccccccccccc};

llvm-svn: 236992
clang/lib/Format/FormatToken.cpp
clang/unittests/Format/FormatTest.cpp