Skip to content

fix(core): scanner ignores files inside VCS #6839

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 15, 2025
Merged

Conversation

ematipico
Copy link
Member

@ematipico ematipico commented Jul 11, 2025

Summary

Closes #6838
Closes #6797
Closes #6784

This PR fixes a bug where the scanner didn't ignore files that are declared inside the root ignore files.

While it doesn't cover all cases, with this fix we give to the root ignore file the same capabilities and semantics as files. includes.

This PR also fixes a bug where the language server didn't correctly ignore certain files when using the VCS integration, and inside the root ignore file there were globs like dist/.

Test Plan

I did some manual testing. I also added a couple of tests.

Docs

biomejs/website#2679

Copy link

changeset-bot bot commented Jul 11, 2025

🦋 Changeset detected

Latest commit: 26c9791

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

@arendjr arendjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, your fixes are based on correctly storing the root settings, but the logic for checking ignore files didn't actually change? It seems then that is_root_ignored() can indeed be safely removed, because I don't see it being used right now.

Regarding the test, I think it would be good to add a case watcher.tests.rs. There's already a few tests there that you can draw inspiration from, and you can use it to create one that shows that a watcher notification doesn't result in an ignored file getting opened. And then it would probably be good to add a second one to show that a non-ignored file does get opened, because such a test seems to be missing still, but we would need one for contrast.

@ematipico
Copy link
Member Author

PR description updated. Code updated and changesets added.

@ematipico ematipico requested review from a team July 12, 2025 08:52
@ematipico ematipico force-pushed the fix/ignore-files-scanner branch 2 times, most recently from c6f3a3f to d6127ee Compare July 12, 2025 08:55
@ematipico ematipico requested a review from arendjr July 12, 2025 09:00
@ematipico ematipico force-pushed the fix/ignore-files-scanner branch from a6874f9 to 1ebcf99 Compare July 14, 2025 07:05
@ematipico
Copy link
Member Author

If I understand correctly, your fixes are based on correctly storing the root settings, but the logic for checking ignore files didn't actually change? It seems then that is_root_ignored() can indeed be safely removed, because I don't see it being used right now.

Now that the code is updated, yes, the PR also fixes the logic that checks if a file is ignored. When we have glob like dist/ inside .gitinogre, and we open a file inside the dist/ folder, that file wasn't ignored and I could see diagnostics.

That's because dist/ doesn't match dist/file.js. Not sure if this is a bug in the library. I assume it's not. This means that I had to come up with a workaround: we crawl upward the path until we reach the working directory. If there's a match, the file is ignored.

Copy link
Contributor

@arendjr arendjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we add tests for all issues? With so many issues solved in one PR it's become a bit hard to track which parts are related to which issue.

Nevertheless I'm very happy with these improvements, but we need to exclude the upwards matching for the scanner use case.

@github-actions github-actions bot added A-Core Area: core A-LSP Area: language server protocol labels Jul 14, 2025
ematipico and others added 3 commits July 14, 2025 13:59
Co-authored-by: Arend van Beelen jr. <arend@arendjr.nl>
@ematipico ematipico requested a review from arendjr July 14, 2025 12:12
@ematipico
Copy link
Member Author

@arendjr please review the PR. I applied your suggestions, but they didn't reach the Workspace level, which is good.. I also added more tests.

@ematipico ematipico requested a review from arendjr July 14, 2025 17:16
@ematipico
Copy link
Member Author

Tested locally again, and I can see now regressions or CPU/RAM peaks

@arendjr
Copy link
Contributor

arendjr commented Jul 14, 2025

@ematipico I see, the watcher is now calling is_ignored_by_scanner(). I thought that method contained the business logic of checking which files are ignored by the scanner (as the name implies), but really it's only checking which files are explicitly ignored through the experimentalScannerIgnores. The full logic of which files are handled by the scanner is in scanner.rs, in the can_handle() method. I don't mind moving that logic in its entirety to the is_ignored_by_scanner() method (be careful, you need to inverse it of course). But then I think the logic still needs to be extended with the ignore_kind as well.

@ematipico ematipico force-pushed the fix/ignore-files-scanner branch from ffb3c9f to bc87585 Compare July 15, 2025 13:15
@ematipico ematipico requested a review from a team July 15, 2025 13:15
@ematipico ematipico marked this pull request as draft July 15, 2025 13:19
@ematipico ematipico marked this pull request as ready for review July 15, 2025 13:29
Copy link
Contributor

@arendjr arendjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥳

@ematipico ematipico merged commit 4cd62d8 into main Jul 15, 2025
12 checks passed
@ematipico ematipico deleted the fix/ignore-files-scanner branch July 15, 2025 13:59
@github-actions github-actions bot mentioned this pull request Jul 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-CLI Area: CLI A-Core Area: core A-LSP Area: language server protocol A-Project Area: project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 OS file watchers exhausted / very high resource consumption 🐛 high memory usage 🐛 Memory leak in biome.exe
2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy