Matsuuu / custom-elements-language-server

Custom Elements Language Server provides useful language features for Web Components. Features include code actions, completions, diagnostics and more.
BSD 3-Clause "New" or "Revised" License
83 stars 0 forks source link

VSCode not working with symbol suggestions #22

Closed matteematt closed 11 months ago

matteematt commented 1 year ago

Hi

I am not sure if you remember but we had a brief discussion on the issue page for the custom elements analyzer here.

I am still investigating my method and we are hoping we get the go-ahead to open source it at some point and then we can compare methods. For now though, I have run into an issue.

Esentially in vscode it has strange behaviour if trying to autocomplete a string with a symbol such as @ in it. An example is if we have

<custom-element @cl(cursor)></custom-element>

where (cursor) is where the cursor is. We want to match @cl and then suggest @click=${x => } etc. This doesn't quite work in VSCode.

I raised an issue here https://github.com/microsoft/vscode/issues/183200 which also shows it working in vim but not in vscode. The person respond, and I understand the response at a high level, but I am struggling to implement their suggestion. Have you come across this issue?

Matsuuu commented 1 year ago

Heya,

Thanks for raising the issue at vscode. This is something I've been meddling a bit with myself.

From the top of my head I remember having some issues with completions not triggering immediately but I handle the textobjects now through a custom system to match the special characters too and through this approach I'm able to manage the completion items as "with" or "without" the special markings

matteematt commented 1 year ago

The answer I received from VSCode sounded more like there was something I was doing wrong, but I am still looking at it.

I can see in your code here that I am taking a very similar approach to you with generating the event values.

but I handle the textobjects now through a custom system to match the special characters too

Would you mind pointing me towards the bit in the code where you're doing that please? That might help me out

Matsuuu commented 1 year ago

Would you mind pointing me towards the bit in the code where you're doing that please? That might help me out

Pretty much the whole action-context.ts is setup to provide a clear "Action Context" for me by traversing the nodes of the code manually, and determining their uses

https://github.com/Matsuuu/custom-elements-language-server/blob/main/lib/custom-elements-languageserver-core/src/scanners/action-context.ts

matteematt commented 1 year ago

Is the important part for vscode to ensure that you send back a textSpan object which contains the cursor and also the string that contains the symbol (e.g. @)?

Matsuuu commented 1 year ago

As far as I remember, it was crucial to return the extra characters with the textspan to have the completion actually fill it out.

I can't completely remember the implementation and haven't had time to read through your vscode issue comments thoroughly through yet

matteematt commented 1 year ago

No worries and no rush, I appriciate any help that you can give me!

return the extra characters with the textspan

What exactly do you mean by "extra characters" sorry? Do you mean you need to return the @? (Because I am already doing that as far as I am aware

I will have a play around and see what I can do. It is strange that VSCode behaves strangely with the specification when they're both maintained by Microsoft as far as I am aware

Matsuuu commented 11 months ago

I'll be closing this as the discussion has gone stale. Feel free to open up again if need be

matteematt commented 11 months ago

Yeah no worries. For future reference, it was just sending the characters like @ back in the text span. Initially when I was running into issues with that method it was because I had an off by one issue with my textSpan alignment

Matsuuu commented 11 months ago

Ah, classic :)