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

[Angular] Unnecessary newline before ending angle bracket #6241

Open
voithos opened this issue Jun 21, 2019 · 3 comments
Open

[Angular] Unnecessary newline before ending angle bracket #6241

voithos opened this issue Jun 21, 2019 · 3 comments
Labels
lang:angular Issues affecting Angular template (not general JS/TS issues used for Angular) type:bug Issues identifying ugly output, or a defect in the program

Comments

@voithos
Copy link
Contributor

voithos commented Jun 21, 2019

Prettier 1.18.2
Playground link

--parser angular

Input:

Blah blah blah blah blah <span>{{ thing }}</span>.

Output:

Blah blah blah blah blah <span>{{ thing }}</span
>.

Expected behavior:
The newline should not be added; the original html was already fine. It appears to occur whenever non-whitespace is added directly after the angle bracket, presumably to make long spans of text easier to read? I think it's doing it too eagerly, if that's the case; there's still plenty of room on the line.

This might be related to #5667, although that one is talking about template strings with --parser typescript.

@j-f1
Copy link
Member

j-f1 commented Jun 21, 2019

Minimal repro:

Prettier 1.18.2
Playground link

--parser angular

Input:

<span>{{x}}</span>.

Output:

<span>{{ x }}</span
>.

@j-f1 j-f1 added lang:angular Issues affecting Angular template (not general JS/TS issues used for Angular) type:bug Issues identifying ugly output, or a defect in the program labels Jun 21, 2019
@voithos
Copy link
Contributor Author

voithos commented Oct 20, 2019

I think I managed to trace the cause of this back to a condition that ends up emitting a hardline. Replacing that with softline fixes this case, but breaks lots of other formats.

I tried replacing the hardline with various permutations of ifBreak(hardline, softline), but can't seem to figure out exactly what to condition on.

@listepo
Copy link

listepo commented Jan 18, 2021

Any news?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang:angular Issues affecting Angular template (not general JS/TS issues used for Angular) type:bug Issues identifying ugly output, or a defect in the program
Projects
None yet
Development

No branches or pull requests

3 participants