Previously, clang-format would try to wrap template string substitutions
by indenting relative to the openening ${. This helped with
indenting structured strings, such as strings containing HTML, as the
substitutions would be aligned according to the structure of the string.
However it turns out that the overwhelming majority of template string +
substitution usages are for substitutions into non-structured strings,
e.g. URLs or just plain messages. For these situations, clang-format
would often produce very ugly indents, in particular for strings
containing no line breaks:
return `<a href='http://google3/${file}?l=${row}'>${file}</a>(${ row },${ col }): `;
This change makes clang-format indent template string substitutions as
if they were string concatenation operations. It wraps +4 on overlong
lines and keeps all operands on the same line:
return `<a href='http://google3/${file}?l=${row}'>${file}</a>(${ row},${col}): `;
While this breaks some lexical continuity between the ${ and row}
here, the overall effects are still a huge improvement, and users can
still manually break the string using + if desired.
This is not the right way to implement this:
will be formatted differently from