Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workspace/didChangeWatchedFiles never triggered under /tmp through registered successfully #4616

Closed
oxalica opened this issue Apr 28, 2023 · 1 comment

Comments

@oxalica
Copy link
Contributor

oxalica commented Apr 28, 2023

Result from CocInfo

vim version: VIM - Vi IMproved 9.0 9001441
node version: v18.15.0
coc.nvim version: 0.0.82-b7375d5f 2023-01-30 05:09:03 +0800
coc.nvim directory: /nix/store/kppjv8524nb63jc8zsh5g5ycss6snf0k-vimplugin-coc.nvim-2023-01-29
term: tmux
platform: linux

Describe the bug

In the code:

if (root.startsWith('/tmp/') || root.startsWith('/private/tmp/')) return false

Any directory (recursively) under /tmp is ignored from watching. I can understand watching the full /tmp is problematic, but it's reasonable to create a /tmp/some-test-project/ and use coc.nvim in it for testing. We should allow this case.

EDIT: vscode watches files successfully and can correctly emit change events for /tmp/some-dir/some-file.

Reproduce the bug

Language server request:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "client/registerCapability",
  "params": {
    "registrations": [
      {
        "id": "workspace/didChangeWatchedFiles",
        "method": "workspace/didChangeWatchedFiles",
        "registerOptions": {
          "watchers": [
            {
              "globPattern": {
                "baseUri": "file:///tmp/flake",
                "pattern": "flake.lock"
              }
            },
            {
              "globPattern": {
                "baseUri": "file:///tmp/flake",
                "pattern": "flake.nix"
              }
            }
          ]
        }
      }
    ]
  }
}

Success response from coc.nvim:

{"jsonrpc":"2.0","id":1,"result":null}

But it never generates any notifications since the watched files are under /tmp.

Expected behavior

  1. /tmp can be an invalid watching directory, but /tmp/some-dir should not.
  2. If coc.nvim cannot fulfill the watching request (eg. invalid watching directory, or watchman is not installed), it should return an error response for easier debugging. It also allows the server to fallback to server-side watching mechanism.
@fannheyward
Copy link
Member

Maybe we can replace the startWith checking with must equal, to stop watching /tmp but /tmp/some-dir not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants