-
-
Notifications
You must be signed in to change notification settings - Fork 475
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
🐛 Import sorting breaks with a particular import line when saving in VSCode #1570
Comments
Seems to be problematic in this case too:
But not in this:
The @ symbol seems to be the reason here. |
Can you share a playground link? |
I can't repro on playground, just vscode |
Then you'll have to share a reproduction. This will help us to identify the issue |
I don't have a working reproduction offhand since it seems to have to do with combination of |
@ematipico here's a simple reproduction showing the issue I'm having (maybe not related?): Before save (swapped imports to be out of order) fwiw I also just tried disabling |
Sorry @kainosnoema , this isn't a reproduction. We need to be able to reproduce the issue. A repository would be great. Without that , we can't help. |
I’ll try enabling |
I have also been experiencing this issue. It seems to be because there is many Biome agents running and happens if I have left my Mac on overnight. If I hover over a Biome warning or error I can see the error repeated, sometimes 20 times. Closing VSCode completely does fix the issue and Biome suggestions are no longer duplicated. So I would suggest the issue is with Biome seemingly restarting without killing the previous process for some reason? |
I wonder to what extent this issue and #1584 are related. I'm getting the impression both situations may be caused by having too many daemons running. As far as I see, I also only see Mac users in these threads. So if there's a non-Mac user experiencing this, please raise your voice, since it might help us figure out in which direction to look. |
We just published a nightly with a possible fix: https://github.com/biomejs/biome/releases/tag/cli/v1.5.2-nightly.91c7730 It would be great if someone can try it, and let us know. |
Still a problem on 1.5.3 |
Hasn't happened to me since 1.5.2-dev and 1.5.3 🤔 |
I'm not sure how or why... but disabling reenabling plugin seemed to work afterwards... I'll keep you posted |
Thank you all for confirming. For anyone coming here , to apply the fix you must restart your VSCode after updating to Biome 1.5.3. There was an issue in the LSP. |
Today I heard reports from several co-workers that seem to be running into this issue still, all on 1.5.3. Unfortunately, I haven't been able to witness it myself, but I did notice just now that I had 4 Biome formatter entries in VS Code, which was also one of the things my co-workers witnessed. So while #1590 seems to have fixed #1584 (the issue that two Biome formatter entries appear in VS Code right away), I think there is still a lurking issue that causes additional entries to be registered over time. And my assumption here is that once there are multiple entries, they can still conflict and trigger this behavior. I'm afraid I still have no additional information what might be the root cause however :( |
And just like that, I finally witnessed the imports being messed up with my own eyes too! I'd been keeping the session with 4 Biome entries open, and it further reinforces my suspicion of the mangled imports and duplicate formatter entries being related: The mangled imports I witnessed had one of the imports being repeated 4 times: One thing of note though, this didn't happen to me on Save or by manually using Organize Imports. It happened when I renamed a symbol in one file and VS Code applied the refactoring to update that symbol in another file. Maybe that somehow triggered all four formatters to kick in, causing the renamed symbol to appear 4 times. |
Okay, and now that it happened once, if I use Undo to revert to how the imports were before they got mangled, then hit Save (I have Organize Imports enabled on Save) it mangles it again. Update: One more piece of information: If I invoke Organize Imports explicitly, I get to choose between 5 entries. I think one is VS Code's native Organize Imports, while the other 4 are marked as Biome: I can select any of those 5 entries, and the imports get organized as expected. So the functionality itself is fine. But I hit Save, and it mangles again, presumably because multiple get invoked at the same time. Update: If I reorder imports in another file and Save, it also mangles there. So somehow I've gotten into a state now where it will always mangle if I Save while there are imports that need sorting. Saving files where the imports are already sorted is still fine. |
Is it possible that you enabled the rule https://biomejs.dev/linter/rules/use-import-type/ ? |
It shouldn't be, no... |
I noticed that some of the bugs reported are caused by this very rule. |
Can anyone confirm whether the failing cases in this issue can still be reproducible in the latest version (v1.6.4)? |
Just did little refactoring, removing and shuffling around code and so far it worked flawlessly 👍 But that was only about 15 minutes of coding, I'll report if anything else pops up. |
Yeah I don't think the issue caused by multiple instances are fixed. And there're still failing cases that I'm aware of even there is only one instance. This is a complex issue, but we'll fix it step by step. |
I just want to say you guys are the best, eslint is happily far in the rear view mirror and it's hard to imagine things were any different. Just need that pesky no-hanging-promises and this will be literally perfection in both how it's written and its application. |
First import sorting issue since updating to 1.6.4. It might have something to do with the automatic fixing of the double quotes. If I cmd+z the last fix and then save again it's fixed. In general it’s been working so much better! Thanks for fixing it. Screen.Recording.2024-04-06.at.08.48.29.mov |
After initially enabling the Doing "undo" and formatting again, worked OK. What fixed it for now was restarting VS Code as some of the previous comments have mentioned. |
Looks like this issue is a bit broader and applies to lint rule fixes too: biomejs/biome-vscode#241 |
i run into garbled imports anytime i try to save where i have a regular import and a type import in the same import line |
I just want to report a similar problem that I have encountered. |
@Sec-ant any news on this issue? How could we help? |
@depsimon Sorry, these past few months have been the toughest for me because I have been working on revising my dissertation and preparing for the final defense. I’m having difficulty keeping up with things here. My advice would be to either wait a bit longer or try going through the code yourself. An overview of this issue is here. |
@Sec-ant No need to apologize really :) I don't think I'll be able to help in the code as I never touched Rust, but if I can help by testing & reproducing I'll be glad. Wish you all the best for your defense! |
I hit this issue quite often as well. I had to remove the "source.organizeImports.biome": "explicit" setting because biome would constantly break my imports. |
It's possible you have multiple instances of the server running. Check your task manager, search for the |
I upgraded my global biomejs from 1.6.x to 1.9.x and solved this issue. |
I think the issue is indeed multiple instances of biome running @ematipico. It'd be great to get this fixed though as it's a regular issue my team is having too and having to reload the editor often isn't great. Thanks for all your efforts 🙏 |
Use the preview release of the VSCode extension, that should fix it. |
Environment information
Biome VSCode extension version v2.1.1
What happened?
With organizeImports enabled and this config in workspace:
just add this particular import line to any script that has a bunch of existing imports.
import {MaxInteger32Value } from '@shared/MaxInteger32Value';
Minimal reproducible case below:
Something about this particular string causes havoc by duplicating it, and replacing existing import lines below it. See screenshot
This only happens in VSCode, I can't reproduce it on the playground.
Expected result
Code of Conduct
The text was updated successfully, but these errors were encountered: