Fix brace expansion with range going down #17591
Merged
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 PR fixes an issue where a test was setup wrong. While fixing the test, I also noticed that the actual computation was wrong. There are a few cases we have to make sure they work when working with ranges:
0..10..5
— range going from low to high, with a positive step. This should result in0 5 10
. Already worked.0..10..-5
— range going from low to high, with a negative step. This should result in10 5 0
. This one was broken.10..0..5
— range going from high to low, with a positive step. This should result in10 5 0
. This one was broken.10..0..-5
— range going from high to low, with a negative step. This should result in0 5 10
. Already worked.This technically means that there are multiple ways to do the same thing. And in case of Tailwind CSS the order doesn't really matter because we apply custom sort rules for utilities. Luckily, the order here doesn't have any influence on the actual generated CSS so it's not the end of the world to support it.
Intellisense does use a more heavy brace expansion library, and if we don't support this, it also means that you can see a preview of generated classes without generating the actual classes. This also fixes that.
E.g.: Note how the preview shows the correct values, but nothing has been generated (this is before the change of this PR).
Fixes: #17576
Test plan
a/{10..0..5}/b
), which faileda/{10..0..-5}/b
)