{{ message }}
Repository navigation
Ensure earlier @source is not accidentally ignored by later @source - #20335
Merged
Merged
Conversation
When using `@source` pointing to a specific file, then we want to make sure that we ignore _other_ files since they are not listed explicitly. E.g.: ```css @source "./nested/index.html"; @source "./index.html"; ``` To ensure that these patterns don't read other files, we inject a `*` ignore pattern before it. You can think of this being expanded to: ```rs Ignored { base: "/project/src/nested", pattern: "*" } Pattern { base: "/project/src/nested", pattern: "/index.html" } Ignored { base: "/project/src", pattern: "*" } Pattern { base: "/project/src", pattern: "/index.html" } ``` The problem with this is that the `Ignored { base: "/project/src", pattern: "*" }` pattern results in ignoring the `nested` folder as well. We could switch the order in user land, but that's going to be hard to maintain. Instead we should scope the ignore pattern to the _current_ path only, and not deeply nested. In other words, the pattern should become: ```diff - * + /* ```
Contributor
Contributor
This was referenced Oct 21, 2026
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 PR fixes an issue where an
@sourcepointing to a file in a nested folder was not scanned when a later@sourcepointed to a file in a parent folder.E.g.:
When using
@sourcepointing to a specific file, then we want to make sure that we ignore other files since they are not listed explicitly. To ensure that these patterns don't read other files, we inject a*ignore pattern before it. You can think of the above being expanded to:The problem with this is that the
Ignored { base: "/project/src", pattern: "*" }pattern results in ignoring thenestedfolder as well. This means that we never even walk into thenestedfolder, so the earlier@source "./nested/index.html"never matches anything.We could switch the order in user land, but that's going to be hard to maintain (and order matters for undoing/redoing earlier rules, so we can't re-order internally either). Instead, we can scope the ignore pattern to the current path only, and not deeply nested. In other words, the pattern should become:
It's a very subtle difference, but the pattern from above will now become:
Ignored { base: "/project/src/nested", pattern: "*" } Pattern { base: "/project/src/nested", pattern: "/index.html" } - Ignored { base: "/project/src", pattern: "*" } + Ignored { base: "/project/src", pattern: "/*" } Pattern { base: "/project/src", pattern: "/index.html" }We already do this when an unrestricted root (e.g.
@source "./nested") lives inside the base of a restricted pattern. This works because every source base is also its own walk root, and a/*pattern only matches direct children so it can't ignore anything when walking from the nested root itself.This PR extends that same check to restricted pattern bases: if another
@sourcepattern has its base nested inside the current base, we emit/*instead of*.Note that we only relax the pattern to
/*when such a nested root actually exists. Sibling folders that no@sourcepoints into (e.g. anignore-mefolder next tonested) are still direct children, so they still match/*and are never walked.Fixes: #20333
Test plan
Before:

After:

Notice that the
text-green-500now appears as expected.