Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Watch .prettierignore for cache invalidation#3943

Merged
ntotten merged 1 commit intomainfrom
fix/prettierignore-watcher
Jan 21, 2026
Merged

Watch .prettierignore for cache invalidation#3943
ntotten merged 1 commit intomainfrom
fix/prettierignore-watcher

Conversation

@ntotten
Copy link
Member

@ntotten ntotten commented Jan 21, 2026

Summary

  • Added a file system watcher for .prettierignore files that triggers cache invalidation when the file changes, is created, or is deleted
  • Uses the same prettierConfigChanged handler as other config file watchers, which clears Prettier's internal cache to ensure fresh ignore data is used

Fixes #3942

Test plan

  • Add or modify a .prettierignore file while the extension is running
  • Verify that the extension respects the new ignore patterns without requiring a reload
  • Test that files previously ignored are now formatted (and vice versa) after modifying .prettierignore

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings January 21, 2026 23:22
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 .prettierignore files that triggers cache invalidation on change, create, or delete events
  • Reuses the existing prettierConfigChanged handler 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);
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
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]>
@ntotten ntotten force-pushed the fix/prettierignore-watcher branch from f8bd9ff to 10db4ab Compare January 21, 2026 23:27
@ntotten ntotten merged commit c58c958 into main Jan 21, 2026
12 checks passed
@ntotten ntotten deleted the fix/prettierignore-watcher branch January 21, 2026 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Watch .prettierignore for cache invalidation

2 participants