[clangd-dev] Confusing error message for invalid rangeLength in didChange request

Sam McCall via clangd-dev clangd-dev at lists.llvm.org
Mon Aug 5 01:34:06 PDT 2019


On Sun, Aug 4, 2019 at 9:26 PM Björn Linse via clangd-dev <
clangd-dev at lists.llvm.org> wrote:

> While working on implementing proper UTF-16 support for a LSP client,
> I received this very confusing error message:
>
> stderr E[12:26:16.762] Failed to update
> /home/bjorn/dev/neovim/src/nvim/ui.c: Change's rangeLength (24)
> doesn't match the computed range length (24).
> ...
> The *EndIndex - *StartIndex should rather be ComputedRangeLength in
> the error message I think.

Indeed, thanks! Fixed in https://reviews.llvm.org/rL367811

Since you're looking at this, I'd mention that the only three places clangd
deals with the encoding are:
 - encoding/decoding LSP `Position` objects
 - handling `TextDocumentContentChangeEvent`
 - producing `ParameterInformation.labelOffsets` as part of signature help
(this one is easy to miss)
I'd be interested if you know of any others we missed!

BTW clangd in particular supports -offset-encoding=utf-8, and encoding
negotiated by LSP extensions[1], but that doesn't help you if you need to
handle arbitrary language servers.

1: https://clangd.github.io/extensions.html#utf-8-offsets
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/clangd-dev/attachments/20190805/50d1fb14/attachment.html>


More information about the clangd-dev mailing list