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

Make empty arrays and dictionaries render compactly even when indent > 0 #501

Merged
merged 6 commits into from
Jul 9, 2023

Conversation

lihaoyi
Copy link
Member

@lihaoyi lihaoyi commented Jul 9, 2023

Fixes #499

We take a similar strategy as we do for adding commas: rather than calling renderIndent immediately after opening a new array/dict and at visitEnd, we instead set an indentBuffered flag and defer the renderIndent until later. Then each flushBuffer call can render the indent where necessary, and visitEnd can perform some additional checks that the collection is not empty before rendering the final indent

Added some basic tests to ExampleTests.scala, since some of this behavior is probably worth showing to users in the documentation

@lihaoyi lihaoyi merged commit ad066a7 into main Jul 9, 2023
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.

Compactly render empty arrays and dictionaries even when indentation is specified
1 participant