Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent Props completion in namespaced component #2202

Closed
huntabyte opened this issue Nov 14, 2023 · 4 comments
Closed

Inconsistent Props completion in namespaced component #2202

huntabyte opened this issue Nov 14, 2023 · 4 comments
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release.

Comments

@huntabyte
Copy link
Member

huntabyte commented Nov 14, 2023

Describe the bug

I'm noticing that the autocomplete works only if a known prop comes before you attempt to trigger Intellisense.

Here's an example of trying to trigger Intellisense before the prop:
image

Then if you try to trigger Intellisense after the prop, the correct result is displayed:
image

But if you try to use an expression, it also breaks:
CleanShot 2023-11-14 at 15 22 09@2x

Without the expression, all good:
CleanShot 2023-11-14 at 15 22 35@2x

Reproduction

Create a component:

<!-- button.svelte -->
<script lang="ts">
	export let label = "Open menu"
	export let disabled = false
</script>

<button {disabled} aria-label={name}>
	<slot />
</button>

Export it

// index.ts
import Root from './button.svelte'
export { Root }

Attempt to get Intellisense to work when using it:

<script lang="ts">
	import * as Button from '$lib'
</script>

<Button.Root >
	Open
</Button.Root>

Expected behaviour

Once a space has been inserted after the .Root, Intellisense should display the props.

System Info

  • OS: MacOS
  • IDE: VSCode

Which package is the issue about?

No response

Additional Information, eg. Screenshots

No response

@huntabyte huntabyte added the bug Something isn't working label Nov 14, 2023
@jasonlyu123 jasonlyu123 changed the title Autocomplete intellisense inconsistent before/after known prop Inconsistent Props completion in namespaced component Nov 16, 2023
@AdrianGonz97
Copy link
Member

I'd like to add some additional quirks that I've found:

This issue doesn't occur for namespaced components that are self-closing:
img

If you don't manually trigger the auto completion prompt (CTRL + SPACE) and instead just add the first letter of a prop, you'll get the proper prop completions for the component:
img

@dummdidumm dummdidumm added the Fixed Fixed in master branch. Pending production release. label Nov 21, 2023
@AdrianGonz97
Copy link
Member

AdrianGonz97 commented Nov 21, 2023

Thanks for the fix @jasonlyu123, it's very much appreciated! 😄 I cloned this repo to test out the changes and noticed 1 issue.

The prop completions don't show correctly when you trigger them when you're 1 space out. It seems like it only triggers when you're two spaces out, as shown here:

gif

With that in mind, I've tested out all of the scenarios where it previously didn't work and they all seem to work now!

Edit:
I reverted back to the older version of the svelte extension and the 2 space trigger to get the correct completions characteristic is present there too 🤔 In that respect, I'm not sure if anything has really changed

Here's a reproduction to demonstrate the cases where it does and does not work: https://github.com/AdrianGonz97/inconsistent-namespace-props-repro

@dummdidumm dummdidumm removed the Fixed Fixed in master branch. Pending production release. label Nov 21, 2023
@jasonlyu123
Copy link
Member

I can't reproduce it with the reproduction. Are you sure the build succeeded? Or maybe you have the svelte.language-server.ls-path config? Or maybe tsc incremental build glitched? I did encounter this when I pulled the commit. But worked after I forced tsc to do a clean build.

@AdrianGonz97
Copy link
Member

@jasonlyu123 Aha, you're correct! After deleting the my local repo and recloning, building and testing again, it seems to be working now. Sorry about that!!

Everything looks to be working beautifully. 😄 Thanks for the help!

@dummdidumm dummdidumm added the Fixed Fixed in master branch. Pending production release. label Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release.
Projects
None yet
Development

No branches or pull requests

4 participants