Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.
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

Description

@albel727

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions