Tweak the pretty-printing of long function definitions #1562
Merged
Tweak the pretty-printing of long function definitions #1562
Conversation
|
Cool! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1562 +/- ##
=======================================
Coverage 90.27% 90.27%
=======================================
Files 65 65
Lines 9981 9988 +7
=======================================
+ Hits 9010 9017 +7
Misses 971 971
🚀 New features to boost your workflow:
|
nhuurre
reviewed
Oct 16, 2025
Collaborator
nhuurre
left a comment
There was a problem hiding this comment.
I'm not sure, I might like aligning with the function name, like this:
array[] int vote_countvote_countvote_countvote_count(
array[] int rating,
array[] int item,
array[] int rater,
int I,
int J
) {
int N = size(rating);
...
Member
Author
|
@nhuurre the formatting is now as you suggest, and the code is much cleaner owing to your suggestions Things I'm still not very happy with:
|
nhuurre
reviewed
Oct 16, 2025
nhuurre
reviewed
Oct 16, 2025
nhuurre
approved these changes
Oct 16, 2025
Collaborator
nhuurre
left a comment
There was a problem hiding this comment.
This is good enough for the original goal, if you want to tweak tricky comment placement you can open a new pull req.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This applies a similar logic to what was added for function calls in #1513. If the function name is long, start the box for it's arguments earlier to allow it to be raggedly formatted below rather than forcing it to indent all the way to the
(.This also makes it so each argument gets its own line when there are many arguments -- this helps with readability, IMO, and is common in formatters in other languages
Consider this example from @nsiccha:
Submission Checklist
Release notes
Improved the formatting of long functions (either with long names or many arguments).
Copyright and Licensing
By submitting this pull request, the copyright holder is agreeing to
license the submitted work under the BSD 3-clause license (https://opensource.org/licenses/BSD-3-Clause)