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

Fix incorrect formatting of ending expression after heredoc #6127

Merged
merged 1 commit into from
May 24, 2018

Conversation

asterite
Copy link
Member

Fixes #6121

It was a bit tricky to fix because the formatter works like this:

  • To format an expression, like 1 or 1 + 2, the formatter traverses that and outputs/fixes that (corrects whitespace, etc.), but it doesn't insert a newline
  • Newline is inserted after an expression is formatter only if more expressions come, or if it's before an "end", etc.
  • But a heredoc already ends with a newline (it's probably the only expression with this characteristic), so a second newline must not be placed in the above cases

That's why a newline is now inserted after writing a heredoc, and in some places I check that if a newline was already printed, don't print it again.

The issue also happened with other closing stuff, like }}, ], }, not only %}.

@asterite asterite self-assigned this May 24, 2018
@asterite asterite changed the title Fix incorrect formatter of ending expression after heredoc Fix incorrect formatting of ending expression after heredoc May 24, 2018
@asterite asterite force-pushed the bug/6121-formatter-heredoc branch from 6abda76 to 241e3e3 Compare May 24, 2018 14:00
@asterite asterite force-pushed the bug/6121-formatter-heredoc branch from 241e3e3 to a725095 Compare May 24, 2018 14:59
@RX14 RX14 added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler topic:tools:formatter labels May 24, 2018
@asterite asterite merged commit bc04afd into master May 24, 2018
@bcardiff bcardiff added this to the Next milestone May 24, 2018
@straight-shoota straight-shoota deleted the bug/6121-formatter-heredoc branch November 16, 2021 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler topic:tools:formatter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Formatter issue in heredoc in macros
3 participants