[PATCH] D37142: clang-format: [JS] simplify template string wrapping.

Martin Probst via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 28 02:21:30 PDT 2017

mprobst added inline comments.

Comment at: lib/Format/ContinuationIndenter.cpp:1139
+  // On lines containing template strings, propagate NoLineBreak even for dict
+  // and array literals. This is to force wrapping an initial function call if
djasper wrote:
> This is not the right way to implement this:
> - This is a static computation that we could do ahead of time. Doing it inside the combinatorial exploration of solutions is a waste.
> - You are doing this always, even in code that doesn't have template strings or isn't even JavaScript.
> - This can lead to unexpected behavior if the template string is in a completely unrelated part of the statement. E.g.
>   someFunction(`test`, { ... });
> will be formatted differently from
>   someFunction('test', { ... });
Ack. Do you have suggestions?

I could introduce a `bool  ParenState::NoLineBreakMustPropagate;` that controls this behaviour.


More information about the cfe-commits mailing list