Watch .prettierignore for cache invalidation#3943
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds automatic cache invalidation when .prettierignore files change, eliminating the need to reload VS Code when modifying ignore patterns.
Changes:
- Added a file system watcher for
.prettierignorefiles that triggers cache invalidation on change, create, or delete events - Reuses the existing
prettierConfigChangedhandler to clear Prettier's internal cache, ensuring consistent behavior with other config file watchers
Comment on lines
+162
to
+167
| // Watch .prettierignore for changes to invalidate ignore cache | ||
| const prettierIgnoreWatcher = | ||
| workspace.createFileSystemWatcher("**/.prettierignore"); | ||
| prettierIgnoreWatcher.onDidChange(this.prettierConfigChanged); | ||
| prettierIgnoreWatcher.onDidCreate(this.prettierConfigChanged); | ||
| prettierIgnoreWatcher.onDidDelete(this.prettierConfigChanged); |
There was a problem hiding this comment.
The .prettierignore watcher implementation lacks test coverage. Since the repository has comprehensive testing for other config file watchers (see src/test/suite/config-watcher.test.ts), consider adding a similar test to verify that changes to .prettierignore files are properly detected and that formatting behavior updates accordingly without requiring an extension reload.
When users modify .prettierignore, the extension may use stale ignore data because Prettier caches file info. This adds a file system watcher for .prettierignore that clears the cache on change, create, or delete events, similar to how other config files are already watched. Fixes #3942 Co-Authored-By: Claude Opus 4.5 <[email protected]>
f8bd9ff to
10db4ab
Compare
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.
Summary
.prettierignorefiles that triggers cache invalidation when the file changes, is created, or is deletedprettierConfigChangedhandler as other config file watchers, which clears Prettier's internal cache to ensure fresh ignore data is usedFixes #3942
Test plan
.prettierignorefile while the extension is running.prettierignore🤖 Generated with Claude Code