Stream: t-compiler/rust-analyzer

Topic: Snippets don't work in assists


Jonas Schievink [he/him] (Mar 26 2021 at 18:02, on Zulip):

I'm trying to make an assist insert snippets, but they seem to be interpreted as normal text. Is this not supported?

Jonas Schievink [he/him] (Mar 26 2021 at 18:02, on Zulip):

It looks like extract_function is also trying to do this, but that also doesn't work for me

Laurențiu (Mar 26 2021 at 18:03, on Zulip):

I think I just ran into this on "extract variable"

Jonas Schievink [he/him] (Mar 26 2021 at 18:05, on Zulip):

huh, according to the LSP spec snippets are only for completion? do we have to use ChangeAnnotation in assists?

matklad (Mar 26 2021 at 18:10, on Zulip):

@Jonas Schievink [he/him] snippents in assists are our custom extension

Jonas Schievink [he/him] (Mar 26 2021 at 18:10, on Zulip):

oh

matklad (Mar 26 2021 at 18:11, on Zulip):

They are almost as hacky as inlay hints, so they might got boroken by something

Jonas Schievink [he/him] (Mar 26 2021 at 18:12, on Zulip):

I'll open an issue

Jonas Schievink [he/him] (Mar 26 2021 at 18:14, on Zulip):

https://github.com/rust-analyzer/rust-analyzer/issues/8208

Jonas Schievink [he/him] (Mar 26 2021 at 18:15, on Zulip):

hmm, but if they work like completion snippets $0 indicates the final cursor position, not that the token at that position is actually a snippet

Jonas Schievink [he/him] (Mar 26 2021 at 18:16, on Zulip):

setting the cursor position also doesn't always work right though

Lukas Wirth (Mar 26 2021 at 18:18, on Zulip):

This works fine for me :thinking:

Jonas Schievink [he/him] (Mar 26 2021 at 18:20, on Zulip):

I'm on VS Code 1.54.2

Lukas Wirth (Mar 26 2021 at 18:20, on Zulip):

I'm on 1.54.3

Jonas Schievink [he/him] (Mar 26 2021 at 18:36, on Zulip):

hmm, no, doesn't work right after updating to that version either

ivan770 (Mar 27 2021 at 15:49, on Zulip):

A bit late, but I found that placeholderLength always equals zero. I'm not even sure whether it worked before or not, since snippets that we are providing to clients (at least in cases like let $0var_name = 123;) doesn't contain any info about how much client should select

ivan770 (Mar 27 2021 at 15:50, on Zulip):

Client could guess that it has to select next word however

Jonas Schievink [he/him] (Mar 27 2021 at 16:27, on Zulip):

yeah, now I'm not sure either

Florian Diebold (Mar 27 2021 at 16:32, on Zulip):

I don't think they're supposed to select anything in that case, just put the cursor there

Florian Diebold (Mar 27 2021 at 16:34, on Zulip):

there's other cases like the "Generate function" assist where it does select something

Jonas Schievink [he/him] (Mar 27 2021 at 16:41, on Zulip):

I think it doesn't handle multi-line edits well, and also doesn't support multiple snippets in the same set of text edits

Jonas Schievink [he/him] (Mar 27 2021 at 16:44, on Zulip):

hmm, maybe multi-line edits are fine, but multiple TextEdits are what confuses it

Jonas Schievink [he/him] (Mar 27 2021 at 16:44, on Zulip):

because it just puts my cursor somewhere between the 2 edits

Jonas Schievink [he/him] (Mar 27 2021 at 17:53, on Zulip):

managed to fix it, at least partially

Last update: Jul 29 2021 at 08:00UTC