about summary refs log tree commit diff
path: root/src/test/codegen/src-hash-algorithm
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-02-05 11:54:07 +0000
committerGitHub <noreply@github.com>2022-02-05 11:54:07 +0000
commitdd05d12055ac4ce93cdafec87d3507a4259cfa44 (patch)
treefd078e46ff51646e91edfe10cf2bf56b2e200cf7 /src/test/codegen/src-hash-algorithm
parent0feafe8185f23f2b03f1e00b4cd09871f8855adb (diff)
parent1536fc040ab83089afdbd9c1d94d277406ae1656 (diff)
downloadrust-dd05d12055ac4ce93cdafec87d3507a4259cfa44.tar.gz
rust-dd05d12055ac4ce93cdafec87d3507a4259cfa44.zip
Merge #11412
11412: fix: Include `fn`/`type`/`const` keyword in trait impl completion item source ranges r=Veykril a=The0x539

Fixes #11301

If the user has typed, say, `fn de` while implementing `Default`, or `type Ta` when implementing `Deref`, then the resulting completion suggestion will replace the entire "line", which, on its own, is fine.
However, the use of `ctx.source_range()` in this code was meant that `source_range` field of the `CompletionItem` covers only the identifier and not the preceding keyword.

Over in `rust_analyzer::to_proto::completion_item`, this caused the LSP completion response to be broken up into a text edit that replaces `de` with `fn default() -> Self {` and then an entry in `additional_text_edits` to remove the extra `fn`.
I'm pretty sure that using the field like that is (slightly) out of [spec](https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#completionItem):
> Edits must not overlap [...] with the main edit
> Additional text edits should be used to change text **unrelated to the current cursor position**

VS Code supports `additionalTextEdits` in such a way that this doesn't seem like a problem, so has gone largely unnoticed.
The various LSP clients I've tried, however, do not, and as a result this bug has been haunting me for ages.

Co-authored-by: The0x539 <the0x539@gmail.com>
Diffstat (limited to 'src/test/codegen/src-hash-algorithm')
0 files changed, 0 insertions, 0 deletions