Skip to content
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

🐛 Cannot format temporary buffers #460

Open
1 of 3 tasks
JP-Ellis opened this issue Dec 30, 2024 · 7 comments
Open
1 of 3 tasks

🐛 Cannot format temporary buffers #460

JP-Ellis opened this issue Dec 30, 2024 · 7 comments
Labels

Comments

@JP-Ellis
Copy link

JP-Ellis commented Dec 30, 2024

VS Code version

1.97.0-insider

Extension version

2024.12.22126

Biome version

1.9.4

Operating system

  • Windows
  • macOS
  • Linux

Description

Biome is not an available formatter when there is no corresponding file (yet).

Steps to reproduce

  1. Open VSCode
  2. Create a new 'Untitled' tab
  3. Add some JSON content. For example:
    {
      "hello": "word",
         "foo": 1, "bar": 2
    }
  4. In the command palette, go to "Format document with..." and note that Biome is not available.
  5. Save the document, and try (4) again. Note that Biome is available.

Once the document is saved, repeating steps (1)-(4) will show Biome as available, even if the new buffer remains unsaved/in-memory.

Expected behavior

It would be nice if Biome just works for temporary buffers from the start, instead of requiring it to be saved first.

Does this issue occur when using the CLI directly?

Not sure / Not applicable

Link to a minimal reproduction

N/A (no files needed, see steps above)

Logs

No response

@ematipico
Copy link
Member

I believe that's expected because the buffer doesn't have any language assigned to it. From the instructions, it seems you haven't assigned it, which is something you can usually do before saving an Untitled file.

Please try to do so.

@JP-Ellis
Copy link
Author

The language was detected to be JSON. I didn't assign explicitly, but VSCode automatically infers the language from the contents.

@ematipico
Copy link
Member

ematipico commented Jan 2, 2025

That's not the same, if you don't assign a language, the LSP will receive no language identifier, and Biome won't be able to handle it. Can you please show a screenshot of the VSCode file before saving?

@JP-Ellis
Copy link
Author

JP-Ellis commented Jan 2, 2025

Sure, here you go:

image

In addition to the error prompt, also note that in the bottom right corner, JSON is displayed showing the correct auto-detected language. Even if I manually select JSON as that buffer's language, Biome also fails to format the temporary buffer.

@ematipico
Copy link
Member

I can't replicate the issue. Considering the instructions, the reason why in your case you have an issue is becase Biome isn't installed globally (you can't see "Biome" on the bottom right). Even though your settings want to use Biome by default, the extension can't because it can't find any binary.

@JP-Ellis
Copy link
Author

JP-Ellis commented Jan 5, 2025

Strange you can't replicate the issue 🤔

As for your guess that "Biome isn't installed globally": I have the Biome CLI installed through brew and the extension installed in VSCode. I also have the default config as far as the Biome extension is concerned, save for enabling biome.experimental.rename.

I am using VSCode Insiders in case that might impact the behaviour (perhaps with some experimental lazy loading?).

I'll see if I can try and narrow down the cause in case it is an extension on my end and/or a setting.

@nhedger
Copy link
Member

nhedger commented Jan 9, 2025

I tried with both the stable and the insiders versions of VS Code.

In the stable version, I can format the Untitled file using the Format document with... command.

In the Insiders version (1.97.0), the Format document with... command doesn't even show.

In both cases, it doesn't show Biome in the status bar, but I believe this is a bug, and I'll create a new issue should it prove true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants