Open
Description
We are currently allowing add-ons to register file watchers freely, but I just realized this is not a good approach for a few reasons.
- It is better to register for file watching only once with multiple patterns, rather than creating several separate registrations
- If registration IDs are not unique, they will cause orphan LSP client objects that continue to receive file change events as we saw in Notify file events failed - Client is not running #3137
- If add-ons register for the same pattern, like the RuboCop add-on registering for
.rubocop.yml
(same as the Ruby LSP), then the server will receive duplicate changes for those patterns
We need to provide a proper API for file watching registration that provides the LSP with the opportunity to:
- Register them all at once
- Ensure ID uniqueness (it will be a single registration, so that is fixed by default)
- Verify that patterns are unique to avoid receiving the duplicate notifications in the first place
I haven't prototyped anything, but I think we may need a breaking change to expose a nicer API to add-ons. Instead of passing the outgoing_queue
as a Thread::Queue
, it would be better to have our own abstraction so that we can limit what add-ons can pass and ensure that bugs like these cannot happen.