Open ton1517 opened 6 months ago
Your investigation will be VERY USEFUL! Thank you!
As a workaround, you can use --colors=force
.
@ematipico I usually run biome check --apply --stdin-file-path $FILENAME
in 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.
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=force
to this default set
Environment information
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.
--colors off
or not using terminal will result inColorChoice::Never
. https://github.com/biomejs/biome/blob/fec262f1593c53e4d6c46f6934e3e2ebc2144edc/crates/biome_console/src/lib.rs#L94-L114If you run
biome format
in stdin mode, the entire code is output here. https://github.com/biomejs/biome/blob/fec262f1593c53e4d6c46f6934e3e2ebc2144edc/crates/biome_cli/src/execute/std_in.rs#L66-L68Finally, this
write_str
is called. https://github.com/biomejs/biome/blob/fec262f1593c53e4d6c46f6934e3e2ebc2144edc/crates/biome_console/src/write/termcolor.rs#L146In the
write_str
method, convert characters in the case of Windows orColorChoice::Never
. Bygrapheme.chars().nth(0)
, all combining characters output only the first code point. https://github.com/biomejs/biome/blob/fec262f1593c53e4d6c46f6934e3e2ebc2144edc/crates/biome_console/src/write/termcolor.rs#L167-L173codesandbox
https://codesandbox.io/p/devbox/serene-swirles-6z4jfd?embed=1&file=%2Fsrc%2Findex.js%3A5%2C1&workspaceId=6833e942-7d98-4ed2-8f40-9a265aa14215
related issues
Expected result
The output of the code should not be converted anything.
Code of Conduct