Repository navigation
Description
Environment information
CLI:
Version: 1.7.3
Color support: true
Platform:
CPU Architecture: aarch64
OS: macos
Environment:
BIOME_LOG_DIR: unset
NO_COLOR: unset
TERM: "screen-256color"
JS_RUNTIME_VERSION: "v20.12.2"
JS_RUNTIME_NAME: "node"
NODE_PACKAGE_MANAGER: "yarn/4.1.0"
Biome Configuration:
Status: Loaded successfully
Formatter disabled: false
Linter disabled: false
Organize imports disabled: false
VCS disabled: false
Workspace:
Open Documents: 0
What happened?
When using the stdin mode in combination with โ--colors off", some characters are displayed with broken characters.
I'm not a rustacean but have investigated the code.
The broken characters are Combining character which is represented by multiple code points.
fn main() {
println!("{}", "โ ๏ธ".escape_unicode()); // \u{26a0}\u{fe0f}
println!("{}", "aฬ".escape_unicode()); // \u{61}\u{302}
println!("{}", "๏ฝถ๏พ".escape_unicode()); // \u{ff76}\u{ff9e}
println!("{}", "๐จ๐ปโ๐ฆฑ".escape_unicode()); // \u{1f468}\u{1f3fb}\u{200d}\u{1f9b1}
}--colors off or not using terminal will result in ColorChoice::Never.
biome/crates/biome_console/src/lib.rs
Lines 94 to 114 in fec262f
| fn compute_color(colors: ColorMode) -> (ColorChoice, ColorChoice) { | |
| match colors { | |
| ColorMode::Enabled => (ColorChoice::Always, ColorChoice::Always), | |
| ColorMode::Disabled => (ColorChoice::Never, ColorChoice::Never), | |
| ColorMode::Auto => { | |
| let stdout = if io::stdout().is_terminal() { | |
| ColorChoice::Auto | |
| } else { | |
| ColorChoice::Never | |
| }; | |
| let stderr = if io::stderr().is_terminal() { | |
| ColorChoice::Auto | |
| } else { | |
| ColorChoice::Never | |
| }; | |
| (stdout, stderr) | |
| } | |
| } | |
| } |
If you run biome format in stdin mode, the entire code is output here.
biome/crates/biome_cli/src/execute/std_in.rs
Lines 66 to 68 in fec262f
| console.append(markup! { | |
| {output} | |
| }); |
Finally, this write_str is called.
| fn write_str(&mut self, content: &str) -> fmt::Result { |
In the write_str method, convert characters in the case of Windows or ColorChoice::Never.
By grapheme.chars().nth(0), all combining characters output only the first code point.
biome/crates/biome_console/src/write/termcolor.rs
Lines 167 to 173 in fec262f
| if cfg!(windows) || !self.writer.supports_color() { | |
| let is_ascii = grapheme_is_ascii(grapheme); | |
| if !is_ascii { | |
| let replacement = unicode_to_ascii(grapheme.chars().nth(0).unwrap()); | |
| replacement.encode_utf8(&mut buffer); |
codesandbox
related issues
Expected result
The output of the code should not be converted anything.
Code of Conduct
- I agree to follow Biome's Code of Conduct
Activity
ematipico commentedon May 26, 2024
Your investigation will be VERY USEFUL! Thank you!
As a workaround, you can use
--colors=force.ton1517 commentedon May 26, 2024
@ematipico I usually run
biome check --apply --stdin-file-path $FILENAMEin vim.When I add
--colors force, the characters are not broken, but the terminal format code are inserted at the beginning and end of the file.melMass commentedon Nov 18, 2024
I'm experiencing the terminal code issue too now on neovim/macos

The formatter I use, conform, use these args, and in my options I'm adding
--colors=forceto this default setwalkerdb commentedon Apr 24, 2025
@ematipico we are also running into this issue at Notion, where we use biome in a node process to auto-format and
lint --fixtemplate-generated strings of typescript code viachild_process.spawnbefore we write them to file. Our "workaround" so far has been to write the code to temp files and use biome's normal --write mode instead of its stdin approach, but this is slower and also means we have to put the temp file in a similar location to the final source so that the right lint rules are applied, which is more painful to manage.The core issue seems not to be the color handling choice from
termcolorbut rather the conflation of colors and emoji in these two parts of the codebiome/crates/biome_console/src/write/termcolor.rs
Lines 167 to 182 in 020c0ed
biome/crates/biome_console/src/write/termcolor.rs
Lines 204 to 214 in 020c0ed
Colors are generally terminal-only escape characters and will not appear in a source-code file, so they're fine to retain or strip based on a terminal's color support.
Emoji though have semantic meaning and are real parts of the source - by mutating emoji biome is changing the original source in a way that breaks the intention of the code's author. Whether or not a terminal will correctly display the emoji codepoints isn't really relevant, since what we care about is staying true to the content of the source file, not making the output easier to sight-read. It also means that the end-result output is different between the file-handling side of biome and the stdin side of biome, which leads to some confusion.
Just to get a sense of y'all's thinking on this, how would you feel about a PR that removes the emoji-mutating code from the stdout processor? Or that adds some option to retain emoji codepoints while still making other color decisions per
termcolor?ematipico commentedon Apr 25, 2025
Thank you, @walkerdb, for chiming in! Please send a PR; everyone would appreciate it. As for the solution, I don't have strong opinions (or knowledge).
Considering the use case, I believe it's mostly likely to have characters that would break than emojis that would break, so maybe an option to keep emoji codepoints should be fine? Again, I don't have much knowledge, so feel free to take the initiative and go for a solution that suits your needs
ahmafi commentedon Sep 15, 2025
I didn't know that biome's LSP supports code formatting, if you want to use Biome in NeoVim, you can just use the formatter from the LSP, you don't need something like Conform that uses
stdinto format the file. If you are using Conform, you can use thelsp_format = "prefer"orlsp_format = "first"for the languages that are using Biome.I couldn't get the
organize-importsto work with LSP though.lagomcoder commentedon Oct 22, 2025
Can confirm, diacritics are gone too:
kiyoon commentedon Dec 9, 2025
I have the same issue. Any workarounds?
ematipico commentedon Dec 9, 2025
I vibe-coded a possible solution. I might create a preview release so you can test it #8410
Pajn commentedon Dec 17, 2025
This issue should be reopened, the PR does not solve the whole problem, characters like
โare still incorrectly replaced when they appear in the source code.Biome should only tweak its own output depending on the terminal, source code should appear as-is unless there is a lint or formatting rule to change it.
ematipico commentedon Dec 17, 2025
PRs are welcome then. I tried with my limited knowledge but it didn't work
kiyoon commentedon Dec 18, 2025
I also still have the same issue with biome 2.3.10
kiyoon commentedon Dec 18, 2025
biome/crates/biome_console/src/write/termcolor.rs
Lines 182 to 200 in 922b04f
This is clearly the problem. In the PR #8410, you modified certain emojis because they can be problematic in some terminals. The solution is that don't do it just because color is disabled, or rather, do it on actual diagnostic symbols and not the source code if they can be separated.
I would just remove that block and it should be good. (at least for non-Windows)
ematipico commentedon Mar 21, 2026
Closing. The issues has been fixed in one of latest versions of Biome.