Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Use rangeLength in didChange LSP message to enable Emacs support #280

Closed
albel727 opened this issue Apr 27, 2017 · 0 comments
Closed

Use rangeLength in didChange LSP message to enable Emacs support #280

albel727 opened this issue Apr 27, 2017 · 0 comments

Comments

@albel727
Copy link

Due to the way that Emacs text change hooks are implemented, it's not possible for it to generate proper didChange events as per LSP protocol.

This is due to the fact that it can't calculate correct range.end value, only range.start and rangeLength. Why it is so is outlined in microsoft/language-server-protocol#9 discussion, but I can go into more detail if needed. But the end result is that it isn't possible for Emacs to make use of RLS, because presently RLS takes only range.start and range.end into consideration.

Now, since knowing just range.start and rangeLength is also sufficient for proper handling of the event, there is a possibility for RLS to also support Emacs and similar editors by using rangeLength field, if it's present, and falling back to range.end otherwise.

This will allow such editors to send garbage in range.end field, but still stay functional. Hopefully, LSP spec writers will realise the problem and legitimise absence of range.end field in the next version of the protocol.

Note that VSCode also sends rangeLength field, so using Emacs isn't necessary to implement the suggested workaround.

cc @alanz

albel727 pushed a commit to albel727/rls that referenced this issue Apr 28, 2017
Also switch Racer from git -> v2.0,
to avoid conflict with the rls-vfs dep.

Fixes rust-lang#280
@nrc nrc closed this as completed in e61a3d0 May 2, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant