microsoft / microsoft/vscode-languageserver-node

dynamic registration of watchedFiles does not respect files outside workspace

Open
#1,783 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1.8k
Forks
404
Avg merge
2d 8h
Merged PRs (30d)
14

Description

Background

Not sure if this is a bug with the LSP-communication, or it is how VS Code works 🤷. Feels still wrong

Project Setup

- /home/project/
  - .vscode/
    - settings.json
- /home/outside-project/
  - watched-file.txt

Opening the project with code /home/project
My extension has a setting where I can define the path for the watched file.
Example: my-extenion.watchingFiles: "/home/outside-project/watched-file.txt"

Issue

My LSP Server tells VS Code to watch for the file outside its project:

2026-05-29 14:22:37.762 [info] [Trace - 2:22:37 PM] Received request 'client/registerCapability - (0)'.
2026-05-29 14:22:37.762 [info] Params: {
    "registrations": [
        {
            "id": "watcher-file:///home/project",
            "method": "workspace/didChangeWatchedFiles",
            "registerOptions": {
                "watchers": [
                    {
                        "globPattern": "/home/outside-project/watched-file.txt",
                        "kind": 7
                    },
                    {
                        "globPattern": {
                            "baseUri": "file:///home/project",
                            "pattern": "**/tsconfig*.json"
                        },
                        "kind": 7
                    }
                ]
            }
        }
    ]
}

But VS Code does never send a workspace/didChangeWatchedFiles notification to the server, when editing the file.
When watched-file.txt is inside /home/project/ it works as expected with the absolute path.

2026-05-29 14:37:07.043 [info] [Trace - 2:37:07 PM] Sending notification 'workspace/didChangeWatchedFiles'.
2026-05-29 14:37:07.043 [info] Params: {
    "changes": [
        {
            "uri": "file:///home/project/watched-file.txt",
            "type": 2
        }
    ]
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named. Start by reproducing the dynamic client/registerCapability request with the two watched paths, then trace how workspace/didChangeWatchedFiles registrations handle absolute file URIs outside the workspace. Done means the server receives a change notification for edits to /home/outside-project/watched-file.txt while the in-workspace watcher continues to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript, vscode
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.