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(edit): Avoid leading newline on first nested table #362

Merged
merged 3 commits into from Oct 21, 2022

Conversation

epage
Copy link
Member

@epage epage commented Oct 21, 2022

to_string_pretty tries to have newlines between tables but not extra leading/trailing newlines. The leading newline logic was only working if the first table was visible. If it was not visible, we put a newline before the first dotted table.

Now we avoid the newline before the first table, of any kind, and do this more generally with default decor and not just hard coded in to_string_pretty.

See also rust-lang/cargo#11271

When making a table pretty, we try to put newlines between tables.
Since the decor is tracked in each table, we have to protect against
that newline being at the start of the document.  Before, we only
checked if the first item in the document was a table but we didn't
check if that table is visible.  Now we watch for the first visible
table for removing the newline.
This makes the newline skipping available to everyone and not just if
you run `to_string_pretty`
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

1 participant