Skip to content

Faulty registration of workspace/didChangeWatchedFiles #4781

@alanz

Description

@alanz

Your environment

Debian testing, emacs with eglot (or lsp-mode), working on GHC.

Steps to reproduce

Configure emacs to use eglot, open a file in GHC, e.g. GHC.Parser.PostProcess

Look at the log file

Expected behaviour

The registration of workspace/didChangeWatchedFiles should either use separate IDs if multiple, or multiple file watchers for one only

Actual behaviour

We get multiple client/RegisterCapability requests for workspace/didChangeWatchedFiles all having the same id, globalFileWatches.

The spec for Registration gives

/**
 * General parameters to register for a capability.
 */
export interface Registration {
	/**
	 * The id used to register the request. The id can be used to deregister
	 * the request again.
	 */
	id: string;

	/**
	 * The method / capability to register for.
	 */
	method: string;

	/**
	 * Options necessary for the registration.
	 */
	registerOptions?: LSPAny;
}

The id is intended to provide a way to unregister, which means the registration is indexed by this. Most clients will either unregister a pre-existing registration against an id before registering a new one (eglot), or overwrite it.

The registrationParams interface allows multiple watch specs for a single id, so this may be the simplest way to resolve the information.

Debug information

Log excerpt

[jsonrpc] e[16:57:03.693]   <-- client/registerCapability[3] {"id":3,"jsonrpc":"2.0","method":"client/registerCapability","params":{"registrations":[{"id":"globalFileWatches","method":"workspace/didChangeWatchedFiles","registerOptions":{"watchers":[{"globPattern":"/home/alanz/mysrc/git.haskell.org/worktree/bisect/hie.yaml","kind":7}]}}]}}
[jsonrpc] e[16:57:06.966]   --> client/registerCapability[3] {"jsonrpc":"2.0","id":3,"result":null}
[jsonrpc] e[16:57:06.966]   <-- client/registerCapability[4] {"id":4,"jsonrpc":"2.0","method":"client/registerCapability","params":{"registrations":[{"id":"globalFileWatches","method":"workspace/didChangeWatchedFiles","registerOptions":{"watchers":[{"globPattern":"/home/alanz/mysrc/git.haskell.org/worktree/bisect/.hie-bios/stage0/compiler/build/GHC/Settings/Config.hs","kind":7}]}}]}}
[jsonrpc] e[16:57:10.125]   --> client/registerCapability[4] {"jsonrpc":"2.0","id":4,"result":null}
[jsonrpc] e[16:57:10.125]   <-- client/registerCapability[5] {"id":5,"jsonrpc":"2.0","method":"client/registerCapability","params":{"registrations":[{"id":"globalFileWatches","method":"workspace/didChangeWatchedFiles","registerOptions":{"watchers":[{"globPattern":"/home/alanz/mysrc/git.haskell.org/worktree/bisect/.hie-bios/stage0/compiler/build/GHC/Cmm/Lexer.hs","kind":7}]}}]}}
[jsonrpc] e[16:57:13.357]   --> client/registerCapability[5] {"jsonrpc":"2.0","id":5,"result":null}

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: needs triagetype: bugSomething isn't right: doesn't work as intended, documentation is missing/outdated, etc..

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions