Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(handlebars): Idempotency issue #8504

Closed
dcyriller opened this issue Jun 5, 2020 · 15 comments · Fixed by #9403
Closed

bug(handlebars): Idempotency issue #8504

dcyriller opened this issue Jun 5, 2020 · 15 comments · Fixed by #9403
Assignees
Labels
area:idempotency Issues with re-printing Prettier’s output lang:handlebars Issues affecting Handlebars (Glimmer) locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:bug Issues identifying ugly output, or a defect in the program

Comments

@dcyriller
Copy link
Collaborator

dcyriller commented Jun 5, 2020

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}}
@alexander-akait alexander-akait added area:idempotency Issues with re-printing Prettier’s output lang:handlebars Issues affecting Handlebars (Glimmer) type:bug Issues identifying ugly output, or a defect in the program labels Jun 5, 2020
@Alonski
Copy link
Contributor

Alonski commented Jun 26, 2020

Anyone want to pair with me on trying to fix this?

@Alonski
Copy link
Contributor

Alonski commented Jun 26, 2020

The really weird thing is that this only seems to happen for <Textarea>
Playground Link

@fisker

This comment has been minimized.

@Alonski

This comment has been minimized.

@Alonski

This comment has been minimized.

@Alonski
Copy link
Contributor

Alonski commented Jun 26, 2020

@fisker Would you be up to pairing with me next week to try and figure this out?

@fisker
Copy link
Member

fisker commented Jun 26, 2020

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

@Alonski
Copy link
Contributor

Alonski commented Jun 26, 2020

Ok :) This is the only thing blocking me from going all in on Prettier in the main app I work on.

@Alonski
Copy link
Contributor

Alonski commented Jun 26, 2020

This seems to have been caused by this PR:
#6354

@dcyriller

This comment has been minimized.

@dcyriller
Copy link
Collaborator Author

dcyriller commented Jun 29, 2020

The bug appears to be in glimmer.

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

@Alonski
Copy link
Contributor

Alonski commented Jun 30, 2020

This PR is probably the "cause" for this issue: tildeio/simple-html-tokenizer#59
Specifically this: https://github.com/tildeio/simple-html-tokenizer/blob/5a7739761ffc4358dd46399b5a2b62da9e0d7ba6/src/evented-tokenizer.ts#L137-L139

Looking at this code I found that <Pre /> is also causing these issues.

@dcyriller

This comment has been minimized.

@rwjblue
Copy link

rwjblue commented Oct 14, 2020

@dcyriller - Updating to @glimmer/[email protected] should resolve this.

@dcyriller
Copy link
Collaborator Author

Awesome, thank you @rwjblue

@github-actions github-actions bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Jan 14, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area:idempotency Issues with re-printing Prettier’s output lang:handlebars Issues affecting Handlebars (Glimmer) locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:bug Issues identifying ugly output, or a defect in the program
Projects
None yet
5 participants