sveltejs / language-tools

The Svelte Language Server, and official extensions which use it
MIT License
1.26k stars 201 forks source link

Suggestions not working in `#each` statement after inserting a dot #1990

Open YummYume opened 1 year ago

YummYume commented 1 year ago

Describe the bug

When using a #each statement and accessing an object's properties, the suggestions will stop working after inserting a dot. See the video below for a better explanation :

https://user-images.githubusercontent.com/61044908/233153418-44ca9a39-9d0c-4278-8f46-eb298dd7a546.mp4

Intellisense is not working as expected after inserting a dot. But if I delete a letter or use CTRL + Space, I get my suggestion testArray as expected. I tested this in multiple scenarios and on a clean editor and it does it too.

What seems weird to me is that this only happens with #each statements, #if, #key and so on are fine. This is more of an annoyance than anything, I am just very used to having my suggestions after inserting a dot.

Reproduction

Using the following code :

<script lang="ts">
    const testObj = {
        testArray: [1, 2, 3],
    };
</script>

{#each testObj as array}
    {array}
{/each}

After inserting a dot, VSCode will not suggest testArray.

Expected behaviour

I would expect to get the usually suggested properties of my object.

System Info

Which package is the issue about?

Svelte for VS Code extension

Additional Information, eg. Screenshots

No response

jasonlyu123 commented 1 year ago

This is a limation we have. See https://github.com/sveltejs/language-tools/issues/1302#issuecomment-1002358234 for the reason. We have a workaround for property access but not for this specific situation. Becuase our workaround might have problems in this case.

YummYume commented 1 year ago

Hi @jasonlyu123, thanks for clarifying things. I suppose since it's a limitation, this can be closed and will (hopefully) be fixed somewhere in the future.

Skycweb commented 1 year ago

I also encountered the same problem

bugproof commented 1 month ago

It also doesn't work inside of each

You can see that unless I close img element with /> it stops working completely. Sometimes even with the tag closed the intellisense doesn't pick up current iterated item.

Animation