-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
🐛 "Source Action" popup box opens when triggering Organize Imports for this particular import statement #356
Comments
Extra Notes: Switching between different versions of the extension (pre-releases and past stables) did not change this behavior, so I must assume that this specific import statement is the cause. I'm surprised that I've never seen the popup before, as I've seen and written some wildly complex import statements. In any case, whether this is a bug or not, I want to be able to choose an action by default. I'm willing to fork the extension and simply remove the feature altogether if I have to. Update: Setting (the setting must be set to |
The source code action is something that you configure via Also, you need to take in consideration that VSCode allows you to create user settings and project settings, which means if your reproduction is still affected by the issue, probably your user settings - applied to all projects - are misconfigured. |
I think you misunderstood my message. You opt-in the import sorting, in your IDE, via settings. Let me check if I am able to reproduce the issue
FYI Import sorting isn't part of the formatter |
With that out of the way, I can't seem to reproduce the issue. I'm assuming this happens because multiple extensions have been registered as import organizers for the language, and VS Code tries to deconflict them with this popup. As said previously, this has never popped up for me, so we'll have to dig a bit more to see what's happening. In the meantime, a couple of things:
Please try crafting a minimal reproduction repository that contains all relevant config and files. You can use |
I am able to reproduce the issue, but in another project, where I have my user settings. Let's wait for a reproduction. |
yes, i've seen you say this multiple times. and yet you tell me to do what your site says, which specifically only talks about the formatter
i understand this is what you think, but this is not what actually happens. as i've shown with concrete proof that if you have no settings whatsoever, it still happens
as i said, it happens in both languages. you can change the file extension to .ts and it will happen. you can remove the typescript specific code, and it will happen. i imagine we could craft a completely new file, but i've never seen this behavior before either
i can't stress this enough. the single file is my environment. quite literally:
there is nothing else i have done or added, so that repository with the 1 file is my working environment
i'll try this now |
and here is the repository https://github.com/ericchase/biome-repro-1726588728166 i was even able to minimize the file contents to nearly nothing. just to reiterate, you don't need any configurations at all to trigger this issue. my next steps will be to test this on another operating system, as it might be specific to windows |
Thanks, I appreciate it. I was able to reproduce the behavior on macOS with your repo and instructions. |
Code actions can change code like a formatter, but they are part of a different LSP request. You can check from the logs that is called Now, with the matter at hand, I wonder if the issue is actually VSCode itself... Or maybe that's how VSCode works? Thanks for the detailed information, I'll have a look in the coming days, and try to understand if it's a spec thing or not. |
after having looked through the extension source code and changing some things, i'd like to believe that the cause is within the actual Biome toolchain source code. with all the testing i've done, i agree with ematipico that this seems to be vscode's way of dealing with multiple ... sources(?) for the actions/commands, and it wouldn't be surprising at all unfortunately, i don't think i have the ability to effectively navigate Biome's source code from scratch, and i barely have enough knowledge/understanding of these source actions to hope to look around vscode's source. if either of you could give me some keywords/concepts to look up and the general location in Biome's source where these actions are coded, then I will go bug hunting to figure out what exactly is the cause and how it can be worked around |
oh, actually, all i changed in the extension code were the config files being used, so the cause might actually be somewhere in the extension code that connects these features to vscode. i didn't know what to look for at that time edit: i forgot for a moment that the main problem is that i could not find a way to tell vscode to use one extension as the default source for these code actions. ultimately, this is probably a missing feature in vscode. i will disable this setting in biome.json for now, as import sorting is one of my least concerns. typescript's sorting is fine |
I did some investigation, and I believe this is a VSCode bug. I tried a different LSP client with different combinations:
I would file an issue against the VSCode repository. |
Never mind, I failed to understand how the "Code Action" menu works. |
VS Code version
1.93.1
Extension version
2.3.0
Biome version
1.9.1
Operating system
Description
Whenever I trigger the "Organize Imports" action in VSCode, either via keyboard shortcut or command palette, I'm now seeing a popup box titled "Source Action" with 2 choices: "Organize Imports (Biome)" and "Organize Imports".
I've looked everywhere for a way to select either one of these actions as a default so that I don't have to see this popup anymore (google search, github issues search both here and in the Biome repo, even chats with multiple AIs). I don't care which one is chosen at this point, I just want to move on without disabling either Biome or any built-in extensions.
Attached screenshot shows the popup box. For the sake of removing any suspicions that this is caused by my setup, I've reproduced the issue in Windows Sandbox with a completely new installation of VSCode, Node/NPM, and Biome/Biome extension. As a bonus, I've shown that this problem also occurs in my setup of VSCodium as well.
I've tried reproducing this issue with a trivial js/ts file that imports A and B from another trivial js/ts file that exports empty A and B functions. For trivial cases, the popup box does not appear, and the imports are organized as expected (as far as i can tell). Therefore, I suspect that complicated import statements are triggering this behavior (which I've never seen before in my life).
Any insight into why this suddenly started happening would be highly appreciated!
Steps to reproduce
The behavior happens whether or not the imported files exist. You only need this 1 file:
Expected behavior
Not sure to be honest. I've never seen the Source Action popup box before, and I couldn't find any information on how to deal with source actions.
Does this issue occur when using the CLI directly?
Not sure / Not applicable
Link to a minimal reproduction
https://github.com/ericchase/biome-extension-issue-asf7sa96876
Logs
The text was updated successfully, but these errors were encountered: