Skip to content

Document requirements of FullTextDocument::update() #24

Open
@bolinfest

Description

@bolinfest

I think there is a subtle edge case that should be documented for FullTextDocument::update() (which currently has no docstring).

Specifically, I believe that each TextDocumentContentChangeEvent passed to update() assumes that its associated ranges are specified using utf-16 as the position encoding (which, as of VS Code 1.81.0, appears to be only position encoding that it supports, though as of version 3.17 of the LSP spec, UTF-8 and UTF-32 are also options an LSP client can offer):

https://docs.rs/lsp-types/latest/lsp_types/struct.PositionEncodingKind.html#associatedconstant.UTF16

Because the position encoding is specified up front when the LSP connection is negotiated so that such metadata doesn't have to be sent with every LSP message that references a Range or Position, the position encoding cannot be determined for an isolated TextDocumentContentChangeEvent event.

To that end, I think the docs for update() should include a disclaimer that it assumes the utf-16 position encoding.

Ultimately, it might be nice to support other position encodings, though until VS Code bothers to do so, this does not seem pressing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions