Skip to content

Watch .prettierignore for cache invalidation #3942

@ntotten

Description

@ntotten

Problem

The extension watches for changes to Prettier config files (.prettierrc*, prettier.config.*, .editorconfig) and clears the config cache when they change. However, .prettierignore is not included in this watch list.

When a user modifies .prettierignore, the extension may continue using stale ignore data until VS Code is reloaded.

Proposed Solution

Add a file system watcher for .prettierignore that triggers cache invalidation.

Location

src/PrettierEditService.ts - alongside existing config file watchers (lines 131-175)

Implementation

// Add to the config file watchers in registerDocumentFormatEditorProviders()
const ignoreWatcher = workspace.createFileSystemWatcher("**/.prettierignore");
ignoreWatcher.onDidChange(this.prettierConfigChanged, this);
ignoreWatcher.onDidCreate(this.prettierConfigChanged, this);
ignoreWatcher.onDidDelete(this.prettierConfigChanged, this);
this.disposables.push(ignoreWatcher);

Impact

  • User Experience: Changes to .prettierignore take effect immediately
  • CLI Parity: CLI always reads fresh ignore data; extension should too
  • Effort: Low - small addition to existing watcher setup

Relevant Files

  • src/PrettierEditService.ts - file watcher registration

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions