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

printer: Simplify the formatting of single-line lists. #243

Merged
merged 2 commits into from
Apr 4, 2018

Conversation

octo
Copy link
Contributor

@octo octo commented Mar 27, 2018

This change splits out the formatting of simple single-line lists. A list is considered "simple" if all of its elements are on one line, all elements are literals (except heredoc) and there are no line comments. As an exception, a heredoc string is allowed when it is the only element in the list.

This fixes an issue with a single-line list with one element and a line comment. The formatter used to pull the closing bracket on the same line (after the comment), causing parse errors.

@octo
Copy link
Contributor Author

octo commented Apr 3, 2018

Rebased on master to fix merge conflicts.

@mitchellh
Copy link
Contributor

One more rebase please ❤️ thank you

octo added 2 commits April 4, 2018 19:34
This change splits out the formatting of simple single-line lists. A list
is considered "simple" if all of its elements are on one line, all
elements are literals (except heredoc) and there are no line comments.
As an exception, a heredoc string is allowed when it is the only element
in the list.

This fixes an issue with a single-line list with one element and a line
comment. The formatter used to pull the closing bracket on the same line
(after the comment), causing parse errors.
@octo
Copy link
Contributor Author

octo commented Apr 4, 2018

@mitchellh Done, thank you! :)

@mitchellh
Copy link
Contributor

Merging. Glad you took a look at this function, the complexity definitely always felt wrong. This looks a lot better.

@mitchellh mitchellh merged commit ef8a98b into hashicorp:master Apr 4, 2018
cclauss added a commit to cclauss/hcl that referenced this pull request Feb 18, 2019
See hashicorp#243 for __%s__ --> __%#v__ fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants