-
Notifications
You must be signed in to change notification settings - Fork 353
Remove empty lines in multiline comments for non-trailing imports #1415
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
base: main
Are you sure you want to change the base?
Conversation
|
Hi! I wanted to try contributing, so took on this one. If all looks good I'd love to take on the trailing comments as well! |
HT154
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution! ❤️
We usually define tests like the one you've added using our snippet tests system instead of adding a test case in a file under pkl-formatter/src/test/kotlin/. You can create a Pkl file under pkl-formatter/src/test/files/FormatterSnippetTests/input. When you run the tests with OVERWRITE_SNIPPETS=1 ./gradlew test the first time a corresponding file with the formatted output will be created under pkl-formatter/src/test/files/FormatterSnippetTests/output. Subsequent test run without OVERWRITE_SNIPPETS set will fail if the output changes. We also have an "internal" IntelliJ plugin that makes it much easier to work with snippet tests, see DEVELOPMENT.adoc for more info on it.
Also, you can run CI checks locally with ./gradlew check so you don't need to wait for a maintainer to approve github actions.
|
Thank you for your feedback @HT154 !! The snippet test system is fantastic! I went ahead and added a snippet test and removed the test case!! Happy to make any other changes needed :) |
| private fun getBaseSeparator(prev: Node, next: Node): FormatNode? { | ||
|
|
||
| return when { | ||
| endsInLineComment(prev) && endsInLineComment(next) -> mustForceLine() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is too broad of a fix. You are changing how every line comment gets formatted.
// foo
// barThe above code will have the newlines removed. You have to fix the import list specifically if you want to remove newlines from there.
This change only cleans up the unnecessary empty lines between multiline comments without attempting to reattach them to imports.
Input:
Old Output:
New Output:
related screenshots:

Related Issue
Fixes #1388