bamboo-soy icon indicating copy to clipboard operation
bamboo-soy copied to clipboard

Expose "Hard wrap at" setting to avoid linebreaks with unintended side effects

Open orischwartz opened this issue 5 years ago • 2 comments

Closure templates has a potentially dangerous white space collapsing policy:

Consecutive lines are joined according to the following heuristic: if the join location borders a template or HTML tag on either side, the lines are joined with no space. If the join location does not border a template or HTML tag on either side, the lines are joined with exactly one space.

Right now there's no way to disable hard-wrapping without changing the default IntelliJ setting in Editor >> Code Style >> Hard wrap at.

Example:

Before

Closure templates will render the end of this as:

... some text some text

{template .hardWrap}
<div>Welcome to Bamboo Soy page. Long text that will break at 120 columns by default some text some text some <strong>text</strong></div>
{/template}

After formatting

Closure templates will render this with a missing space:

... some text sometext

{template .hardWrap}
  <div>Welcome to Bamboo Soy page. Long text that will break at 120 columns by default some text some text some
    <strong>text</strong></div>
{/template}

Guessing the change would have to be somewhere here but I'm not sure:

https://github.com/google/bamboo-soy/blob/cc6227768fda0789a22a9d096fecdf5f898d5731/src/main/java/com/google/bamboo/soy/format/SoyCodeStyleSettingsProvider.java#L44-L46

orischwartz avatar Sep 12 '18 20:09 orischwartz