biome-vscode: š "Source Action" popup box opens when triggering Organize Imports for this particular import statement
VS Code version
1.93.1
Extension version
2.3.0
Biome version
1.9.1
Operating system
- Windows
- macOS
- Linux
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
- Install VSCode or VSCodium
- Install the Biome extension
- Let Biome extension install Biome globally(? or something)
- Open a folder in VSCode
- Add a JS/TS file to the folder
- Come up with some complicated import statement (or use my current file)
The behavior happens whether or not the imported files exist. You only need this 1 file:
import { addBall, GameLoop, karel_y, karel_x, move, start } from './src/lib/commands.js';
import { NodeRef } from './src/lib/ericchase/Web API/Node_Utility.js';
const karel = document.querySelector('#karel') as HTMLElement;
const scene = document.querySelector('#scene') as HTMLElement;
function drawKarel() {
karel.style.left = `${4 + 4 + karel_x * 69}px`; // border + missing width/2
karel.style.top = `${4 + 4 + karel_y * 69}px`; // border + missing height/2
}
const domParser = new DOMParser();
const parseHTML = (html: string) => {
return domParser.parseFromString(html, 'text/html');
};
function createBall(x: number, y: number) {
const ball = addBall(NodeRef(parseHTML(`<div class="ball"><img src="./assets/ball.png" alt="ball" /></div>`).body.children[0]), x, y);
karel.before(ball.as(HTMLElement));
ball.style.left = `${4 + 5 + x * 69}px`; // border + missing width/2
ball.style.top = `${4 + 5 + y * 69}px`; // border + missing height/2
}
GameLoop.subscribe(() => {
drawKarel();
});
createBall(1, 9);
createBall(4, 9);
createBall(5, 9);
createBall(8, 9);
createBall(9, 9);
start(0, 9);
move();
move();
move();
move();
move();
move();
move();
move();
move();
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
C:\Users\WDAGUtilityAccount\Downloads\Biome>biome rage --daemon-logs
CLI:
Version: 1.9.1
Color support: true
Platform:
CPU Architecture: x86_64
OS: windows
Environment:
BIOME_LOG_PATH: unset
BIOME_LOG_PREFIX_NAME: unset
BIOME_CONFIG_PATH: unset
NO_COLOR: unset
TERM: unset
JS_RUNTIME_VERSION: "v22.8.0"
JS_RUNTIME_NAME: "node"
NODE_PACKAGE_MANAGER: unset
Biome Configuration:
Status: unset
Workspace:
Open Documents: 0
Discovering running Biome servers...
--------------------------------------------------------------------
[Trace - 10:31:42 PM] Sending request 'textDocument/codeAction - (31)'.
Params: {
"textDocument": {
"uri": "file:///c%3A/Users/WDAGUtilityAccount/Downloads/Biome/main.js"
},
"range": {
"start": {
"line": 8,
"character": 0
},
"end": {
"line": 8,
"character": 0
}
},
"context": {
"diagnostics": [],
"only": [
"source.organizeImports"
],
"triggerKind": 1
}
}
[Trace - 10:31:42 PM] Received response 'textDocument/codeAction - (31)' in 3ms.
Result: [
{
"title": "Organize Imports (Biome)",
"kind": "source.organizeImports.biome",
"edit": {
"changes": {
"file:///c%3A/Users/WDAGUtilityAccount/Downloads/Biome/main.js": [
{
"range": {
"start": {
"line": 1,
"character": 1
},
"end": {
"line": 1,
"character": 8
}
},
"newText": "GameLoop"
},
{
"range": {
"start": {
"line": 2,
"character": 1
},
"end": {
"line": 2,
"character": 9
}
},
"newText": "addBall"
},
{
"range": {
"start": {
"line": 3,
"character": 1
},
"end": {
"line": 3,
"character": 8
}
},
"newText": "karel_x"
},
{
"range": {
"start": {
"line": 4,
"character": 1
},
"end": {
"line": 4,
"character": 8
}
},
"newText": "karel_y"
}
]
}
},
"isPreferred": true
}
]
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 3
- Comments: 17 (9 by maintainers)
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
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
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:
The provided reproduction contains a
main.jsfile, but the contents appears to be TypeScript (youāre usingas). Not sure if this has an impact?We have no way of reproducing your environment because your reproduction contains only one file. The package.json is missing, the biome configuration is missing, and your VS Code settings are not included.
Please try crafting a minimal reproduction repository that contains all relevant config and files. You can use
npm create @biomejs/biome-reproductionto scaffold a skeleton.