dynamic registration of watchedFiles does not respect files outside workspace · Issue #1783 · microsoft/vscode-languageserver-node · GitHub
Skip to content

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

Open

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

Activity

  1. DavyLandman commented on Jun 17, 2026

    @DavyLandman
    Contributor

    Looks like for out of workspace watches you have to use a relative pattern: https://code.visualstudio.com/api/references/vscode-api#workspace.createFileSystemWatcher (see the "Out of workspace file watching" section in examples).

    Maybe an interesting issue to raise in the VS Code repo that it won't detect the file path is outside the repo and rewrite that internally?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions