Fix completion crash when item.range starts using {inserting, replacing}#954
Conversation
The LSP spec (since 3.16) allows CompletionItem.range to be either a
plain Range or an InsertReplaceRange ({inserting, replacing}). The old
code cast item.range directly to vscode.Range; once clangd starts sending
the newer form, this will crash (llvm/llvm-project#187623).
Narrow the type before extracting the start position, and guard against
a missing range entirely.
…replacing} Fix old formatting issue.
|
cc @timon-ul (I'm intending this as a review request, but I can't actually add you to the "Reviewers" field because you're not a member of the clangd org.) |
|
@JVApen Thanks for the review! Could you merge? I don't have permissions. |
|
I wanted to wait until others had the chance to review, in case I missed something. This looks very trivial, though I've learned others have a different way of looking at patches. Given the explicit request for @timon-ul, I'd like to wait merging until he responded. |
|
Makes sense, thank you! 🙂 |
|
It might make sense to bump the version number here for a new pre-release version and if that's not causing issues, to trigger a real release in a next PR. See https://github.com/clangd/vscode-clangd/pull/876/changes for an example. I would recommend doing this in a separate PR. For X.Y.Z, every odd Y is a pre-release, following the guidelines of vs code |
|
(Agree this looks pretty trivial. I just wanted @timon-ul to okay it since it's related to llvm/llvm-project#187623 which he has been reviewing.) |
|
Just want to say it looks fine, but wanted to be a good reviewer and test the changes, but I am struggeling a bit with setting that up... |
|
Looks good to me, got it to run, works, code also looks good. |
PR created: #956 |
Include support for InsertReplaceEdit in code completion middleware (#954).
The LSP spec (since 3.16) allows CompletionItem.range to be either a plain Range or an InsertReplaceRange ({inserting, replacing}). The old code cast item.range directly to vscode.Range; once clangd starts sending the newer form, this will crash (llvm/llvm-project#187623).
Narrow the type before extracting the start position, and guard against a missing range entirely.