Merge template strings (marked by backticks ``).
Do not format any contents of template strings.
Details
- Reviewers
djasper
Diff Detail
Event Timeline
lib/Format/Format.cpp | ||
---|---|---|
796–797 | I think, I'd find this (very slightly) easier to read as: if (I[0]->IsMultiline || I[0]->NewlinesBefore > 0) IsMultiline = true; | |
811 | Reading the comment for ColumnWidth again, it says: /// \brief The width of the non-whitespace parts of the token (or its first /// line for multi-line tokens) in columns. So, if this turns into a multiline token, we need the length of the first line. The reason is this: var someLongVariableName = `aaaaaaaaa bbbbbbb cccccccc`; While we can't do anything to the content of the template string without affecting the runtime behavior, we need to make the decision of whether or not to break after the "=". For that, we need to know the lengths of the first line of the token. Should be reasonably easy to reproduce in a test :-). | |
813 | I think we need to set LastLineColumnWidth only for MultiLine tokens. It should not have any meaning for single-line tokens. Setting it to LastColumn for non-multiline tokens certainly is confusing. |
lib/Format/Format.cpp | ||
---|---|---|
798 | Can you add a test with two template strings? I think that might do the wrong thing as you need to abort when you find a TT_TemplateString. |
Fix counting of ColumnWidth and LastLineColumnWidth.
Still contains an issue with width counting of tok::unknown tokens.
lib/Format/Format.cpp | ||
---|---|---|
796–797 | Done. | |
798 | It's not strictly needed - if there was a preceding template string, it cannot just equals "", it must have at least opener and closer "`". But it's a reasonable optimization and IMHO adds clarity. | |
811 | As discussed offline, this changed quite a bit. PTAL. | |
813 | Done. |
Looks good, I'll add the test and commit.
lib/Format/Format.cpp | ||
---|---|---|
798 | I agree. Still seems useful to have a test ;-). |
lib/Format/Format.cpp | ||
---|---|---|
798 | Sorry for being unclear, I actually did add one. |
I think, I'd find this (very slightly) easier to read as: