language-tools icon indicating copy to clipboard operation
language-tools copied to clipboard

🐛 BUG: Reload Window Required After Creating Layout or Component for Intellisense to Recognize

Open Daubenmire opened this issue 1 year ago • 11 comments

Describe the Bug

Every time I create a new layout or component and attempt to use it I have to ctrl+shift+p -> Reload Window to refresh VSCode in order for Intellisense to recognize it and not give an error. image image

If I either close VS Code and reopen or I ctrl+shift+p -> Reload Window the component or layout will immediately be available and work correctly. image image

Steps to Reproduce

  1. npm create astro@latest
  2. open blank project
  3. create a new layout (MainLayout.astro for ex.)
  4. create a second layout (AnotherLayout.astro for ex.)
  5. attempt to use <AnotherLayout/> in MainLayout.astro
  6. sometime this second layout is recognized without issue.....
  7. create a third layout (MainHead.astro for ex.)
  8. attempt to use <MainHead/> in MainLayout.astro and it will not be recognized by intellisense and give an error.
  9. delete <MainHead/> tag
  10. reload window
  11. use <MainHead/> tag in MainLayout.astro and it will be recognized and work correctly.

Daubenmire avatar Nov 09 '23 23:11 Daubenmire

If you try to use the quick fix to import the component, does it work?

Princesseuh avatar Nov 10 '23 10:11 Princesseuh

If you try to use the quick fix to import the component, does it work?

Yes the quick fix will bring up a window to allow you to import it.

image

I also just noticed while trying to test this that it looks like the first one I create will work and import correctly after opening a new project but successive ones will not.

I opened VSCode, created layout QuickFix.astro and went to put it in MainLayout.astro and intellisense worked correctly. Making the second layout called AnotherQuick.astro and trying to insert in Mainlayout.astro gave the same bug as reported. I was able to test the quick fix on <AnotherQuick /> and get it to import. Screenshot is from a third layout showing quick fix pop-up.

Daubenmire avatar Nov 10 '23 10:11 Daubenmire

I believe this is a bug in https://github.com/volarjs/typescript-auto-import-cache, thank you for the issue! I'll keep this open and mark it as being upstream.

Princesseuh avatar Nov 10 '23 10:11 Princesseuh

Is there a way to maybe disable the typescript auto import cache in VS Code?

sammwashere avatar Jan 21 '24 22:01 sammwashere

I have the same problem, it seems to happen only on linux.

Brian-ChM avatar Feb 14 '24 04:02 Brian-ChM

I also encountered this issue on macos.

zhibisora avatar Feb 14 '24 12:02 zhibisora

Happens on Windows as well. I also want to add that Astro files still show as suggestions even when they are deleted until the next reload/restart of the extension, it doesn't add the import statements if you do click or press enter on the bugged suggestion.

nasheomirro avatar Feb 24 '24 10:02 nasheomirro

Seems like tsconfig.json is not detected when new file is created

Existing file image vs Freshly created file without reloading the window image

tysian avatar Mar 07 '24 09:03 tysian

For what it is worth: it is enough for me to run "Astro: reload project" to get it working again. That's a lot quicker than reloading the whole window.

einarmagnus avatar Mar 07 '24 11:03 einarmagnus

The latest version of the extension should improve the problem here somewhat, however there are still some issues remaining. Apologies for the inconvenience, it was a tough nut to crack!

Princesseuh avatar Mar 22 '24 21:03 Princesseuh

Same problem on windows. (astro extension v2.8.4)

Reimirno avatar Mar 23 '24 23:03 Reimirno

The vast majority of these issues have been fixed in recent updates and we're getting less and less reports of this happening. There are still some remaining caching issues around deletions that are being worked on independently from this, but I cannot reproduce issues around creating new components anymore.

If this still happens, please create a new issue with reproduction steps!

Princesseuh avatar May 07 '24 13:05 Princesseuh