Skip to content

dynamic registration of watchedFiles does not respect files outside workspace #1783

@Sysix

Description

@Sysix

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
        }
    ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions