Added comment reflow functionality - #4736
Open
achowd32 wants to merge 1 commit into
Open
Conversation
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.
An attempt to close #1687. The comments now reflow as desired. Since it was clarified that we should only ever reflow downward, that is what has been implemented.
The gist of the new change is that
FormatCommentsBetweenwill push entire contiguous, multiline comments in onePrefixedReflowblock. Hardlines are not emitted between comments any more. This allows the modified pretty printer to split each comment block into lines (splitting on\n), and emit carriage returns only where necessary (when overflowing to a new line, or when one comment line fits onto the current line being emitted). That's the best brief explanation I can give of the overarching changes, but I'm happy to answer any questions. I've left comments that hopefully make the changes clear.One thing I'd like to note is that I didn't include any functionality that determines comment structure based on comment content (e.g. "don't reflow onto a line that starts with
-"). It is possible some intentional formatting is disturbed by this and may require manual correction, but I decided to make this first PR since it solves an issue that requires manual correction regardless - hopefully the amount of required manual modifications goes down after this change. That said, if including heuristics like these is critical, I am happy to go back and revise these changes.Please let me know what you think, I am open to any and all feedback.