Support partially formatting method chains#6862
Open
randomPoison wants to merge 17 commits intorust-lang:mainfrom
Open
Support partially formatting method chains#6862randomPoison wants to merge 17 commits intorust-lang:mainfrom
randomPoison wants to merge 17 commits intorust-lang:mainfrom
Conversation
Check the span of the chain against the selected lines to format. Only allow formatting the chain as a single line if the entire chain is covered by the selected range.
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.
Support formatting method chains when only part of the chain is selected with
--file-lines, ensuring that only the selected parts of the chain are modified. Partially addresses #4053.To support this I had to define how chains should be formatted when only part of the chain is selected, since short chains want to be formatted into a single line but we can't do so if only part of the chain was selected. I've opted to have partially-selected chains always be formatted as multi-line chains (i.e. one call in the chain per line, as is the case for long method chains), even if the chain as a whole would be short enough to fit in one line. This means we sometimes get different formatting when formatting the chain as a whole vs formatting only part of the chain, but that seems like the only reasonable approach to take and aligns with the desired formatting described in #4053.
Commit history isn't clean, let me know if I should squash this before it can be merged.