Use rangeLength in didChange LSP message to enable Emacs support #280
Description
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