[BUG] LSP stale index: deleting files via Bash tool does not send workspace/didChangeWatchedFiles (Deleted)

Resolved 💬 4 comments Opened Mar 11, 2026 by ebachle Closed Apr 8, 2026

When files are deleted using the Bash tool (e.g. rm), the LSP client does not send a workspace/didChangeWatchedFiles notification with type: Deleted to the language server. The server (e.g. Pyright) keeps the deleted files in its in-memory index indefinitely, causing findReferences, diagnostics, and symbol searches to return hits from files that no longer exist on disk.

Steps to reproduce

  1. Have a Python project open with Pyright as the language server.
  2. Use the Bash tool to delete one or more .py files (rm path/to/file.py).
  3. Use the LSP tool (findReferences, workspaceSymbol, etc.) on a symbol that was referenced in the deleted files.
  4. The deleted files appear in results as if they still exist.

Expected behavior

After deletion, the language server should no longer report references in the deleted files. The LSP client should send workspace/didChangeWatchedFiles with type: Deleted (or equivalent) for any file removed via the Bash tool.

Actual behavior

Language server returns stale references from deleted files until the server process is manually killed and restarted.

Contrast

The Write and Edit tools correctly trigger textDocument/did* notifications, so edits to existing files are reflected immediately. The gap is specifically file deletion via Bash.

Workaround

Kill the language server process manually; it will restart on the next LSP request.

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗