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

Do not use currentColumn to indent comments when retainLines=true #12260

Merged
merged 2 commits into from Oct 27, 2020

Conversation

ian-craig
Copy link
Contributor

@ian-craig ian-craig commented Oct 26, 2020

Q                       A
Fixed Issues? Fixes #12259
Patch: Bug Fix? Yes
Major: Breaking Change? No
Minor: New Feature? No
Tests Added + Pass? Yes
Documentation PR Link N/A?
Any Dependency Changes? No
License MIT

When babel prints block comments it adds a newline before the comment, then aligns the comment to the current column position. However, with retainLines == true, this.newline() is a noop and the "current" column position when printing the comment is the end of the previous line.

Looks like this additional alignment check isn't supported with retainLines, so I'm just disabling it.

Added the input sample from #12259 as a unit test to confirm it was failing and is now fixed.

@babel-bot
Copy link
Collaborator

babel-bot commented Oct 26, 2020

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/31138/

@existentialism existentialism added pkg: generator PR: Bug Fix 🐛 A type of pull request used for our changelog categories labels Oct 26, 2020
@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 26, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit a0f7062:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

@nicolo-ribaudo
Copy link
Member

Thanks for the PR!

What happens for this input code? (the comment is indented)

{
  const foo = "this is a really long line of text. this is a really long line of text.";

  /**
   * Example
   */
  class A { }
}

@ian-craig
Copy link
Contributor Author

Before this PR, output is

{
  const foo = "this is a really long line of text. this is a really long line of text.";

  /**
                                                                                          * Example
                                                                                          */
  class A {}
}

After this PR, output === unput

@nicolo-ribaudo nicolo-ribaudo merged commit 87a3052 into babel:main Oct 27, 2020
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jan 27, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: generator PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

With retainLines=true, babel indents block comments to end of previous line
4 participants