Page MenuHomePhabricator

[clang-format] Ignore UnbreakableTailLength sometimes during breaking

Authored by krasimir on Jan 22 2018, 6:51 AM.



This patch fixes an issue where the UnbreakableTailLength would be counted towards
the length of a token during breaking, even though we can break after the token.

For example, this proto text with column limit 20

# ColumnLimit: 20  V
foo: {
  bar: {
    bazoo: "aaaaaaa"

was broken:

# ColumnLimit: 20  V
foo: {
  bar: {

because the 2 closing } were counted towards the string literal's UnbreakableTailLength.

Diff Detail

Event Timeline

krasimir created this revision.Jan 22 2018, 6:51 AM
krasimir updated this revision to Diff 130882.Jan 22 2018, 6:53 AM
  • Cleanup
krasimir updated this revision to Diff 130885.Jan 22 2018, 6:54 AM
  • Cleanup
Harbormaster completed remote builds in B14088: Diff 130885.

I don't understand why the closing braces would count towards the string literals UnbreakableTailLength. Isn't that a bug?

I think I understand now. I think I'd prefer pulling all of the "+ UnbreakableTailLength" calculations out of getRemainingLength so that you don't have to pass around the new parameter CanBreakAfter. Instead, only add it if necessary outside of the function.


Forgot to check CanBreakAfter here?

Thanks! I created which does the same in a much simpler way!