Merge --lines ranges that overlap instead of rejecting them - #71
Merged
Merged
Conversation
"--lines=1:5 --lines=3:8" failed with "Overlapping ranges not permitted but found [0..5) overlapping [2..8)" and printed the usage text. The ranges were collected in an ImmutableRangeSet.Builder, which refuses overlapping and even adjacent ranges, so a caller that computes ranges from a diff had to merge them itself, and the same line given twice was an error. This ports google/google-java-format#1093: the ranges are collected in a TreeRangeSet, which merges them, and the usage text says that 1:5 means the first five lines. The mergedLines test comes from upstream; repeatedLines replaces the test that expected the rejection.
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.
Brings over google/google-java-format#1093, a fix from google-java-format 1.22.
The bug
followed by the usage text and exit code 2. The ranges were collected in an
ImmutableRangeSet.Builder, which refuses overlapping and even adjacent ranges, so a caller that computes ranges from a diff had to merge them itself, and the same line given twice was an error.From upstream, with the author kept
TreeRangeSet, which merges them, and the usage text says that1:5means the first five lines. ThemergedLinestest comes with it.Added here
repeatedLinesreplaces the test that expected-lines=1:1 -lines=1:1to be rejected.Checked
--lines=1:5 --lines=3:8on the command line formats lines 1 to 8 and leaves the rest alone../gradlew :open-java-format:teston JDK 21: 1498 tests, all green.