prettier: bug(handlebars): Idempotency issue

Description

<Textarea />

{{#if true}}
  Test
{{/if}}

is formatted to

<Textarea />
{{#if true}}
  Test
{{/if}}

And

<Textarea />
{{#if true}}
  Test
{{/if}}

is formatted to

<Textarea />

{{#if true}}
  Test
{{/if}}

Report

Prettier 2.0.5 Playground link

--parser glimmer
--print-width 40

Input:

<Textarea />
{{#if true}}
  Test
{{/if}}
  
<Textarea />

{{#if true}}
  Test
{{/if}}

Output:

<Textarea />

{{#if true}}
  Test
{{/if}}
<Textarea />
{{#if true}}
  Test
{{/if}}

Expected behavior (maybe):

<Textarea />
{{#if true}}
  Test
{{/if}}
  
<Textarea />

{{#if true}}
  Test
{{/if}}

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 15 (10 by maintainers)

Most upvoted comments

@dcyriller - Updating to @glimmer/syntax@0.62.3 should resolve this.

The bug appears to be in glimmer.

In this AST, the TextNode chars attribute is “” instead of “/n”.

This seems to have been caused by this PR: https://github.com/prettier/prettier/pull/6354

I believe @dcyriller is more familiar with it. Don’t worry, If you have problems, everyone will help.

Oh it just formats again 😃

FYI: There is a show second format option on playground.