biomejs / biome-vscode

Biome extension for Visual Studio Code and VSCodium
https://marketplace.visualstudio.com/items?itemName=biomejs.biome
Apache License 2.0
237 stars 32 forks source link

🐛 Do not warn for downloading Biome in every project #393

Closed aminya closed 1 month ago

aminya commented 1 month ago

VS Code version

Any

Extension version

v2024.10.40751 (pre-release)

Biome version

Any

Operating system

Description

I program in many different projects with a diverse set of programming languages. However, Biome warns about downloading and using the tool in all of them despite the fact that no configuration file is present. This default behaviour is not desirable.

image

Steps to reproduce

Open VsCode in a new project

Expected behavior

Does this issue occur when using the CLI directly?

No

Link to a minimal reproduction

N/A

Logs

N/A
nhedger commented 1 month ago

Thanks for reporting; I agree with you.

This is a bug and is not the intended behavior. This should usually happen when opening files that are not a part of your workspace such as VS Code settings to provide formatting capabilities globally.

To start this global session, the extension needs a Biome binary, which is why it is prompting you to install one. Downloading and installing it should temporarily stop the nagging, though.

If you can reproduce this popup showing consistently, it would be interesting to know more about your setup and what you were doing when the popup appeared.

aminya commented 1 month ago

For example, I opened VsCode in a project where a YAML file was open, and it asked me to install Biome. As it doesn't seem to remember the answer either even in the same project. I prefer if Biome only warned if it detected a Biome config file and the constant warning was opt-in.

nhedger commented 1 month ago

Thanks for the info. Would you be able to provide de minimal reproduction repo?

You can create one with npm create @biomejs/biome-reproduction

nhedger commented 1 month ago

I think I have found part of what causes the issue.

We're using onDidOpenTextDocument to detect when a user opens a file and decide whether a global session should be started. Unfortunately, VS Code fires an event for the following URI whenever I lose focus on the VS Code window and refocus again.

vscode-userdata:/Users/nicolas/Library/Application%20Support/Code/User/settings.json

https://github.com/user-attachments/assets/8b2866f6-c8bd-4f29-b1a2-490a9bdef82d

nhedger commented 1 month ago

Initially, I though that the onDidOpenTextDocument would only listen to user-initiated opens, but it turns out that it can also be triggered when opening files programmatically. When the event was triggered for a file outside of the workspace, it would result in the popup being shown.

I've changed the strategy to rely on the active text editor instead, which should give more precise results.

I'll be publishing the fix short, in the meantime I'm closing this issue.