language-tools
language-tools copied to clipboard
Code completion for expressions in the markup doesn't work properly
Describe the bug Code completion in JavaScript expressions in the markup doesn't work (as least as reliably) as it does in the script tag.
To Reproduce
I have a client object that contains various functions that send fetch requests, when I'm in the <script> and I type client and then hit ., this is the list of suggestions that appears, exactly what's expected:

But when I do the same thing in an {#await} block, for example, this is the list of suggestions:
As you can see, there is all sorts of unrelated stuff in there. I'm assuming this has something to do with this extension or the Svelte language server.
I've had this problem since the beginning, but I always thought "it's probably gonna be fixed soon", and I assumed there was an already-existing issue for it or something.
Expected behavior
I expect to see the members of the client objects properly as they are shown when I do client. in the script tag.
System (please complete the following information):
- OS: Windows 10
- IDE: VSCode
- Plugin/Package: Svelte for VSCode
This is a limitation we currently have. The syntax transformation under the hooks relies on the AST the svelte compiler returned. So it won't work if there's a syntax error in the markup. See sveltejs/svelte#4818. It should be working again once there's no syntax error. Like if you have at least an identifier after ..
This won't be completely fixed anytime soon. What we can do is find a workaround for each case to slightly improve it.