comfy-table
comfy-table copied to clipboard
[BUG] Table rendering without content on Windows
Describe the bug
The table renders with the width calculated correctly, as far as I can tell, but all the cells are empty.
I only see this on Windows (8, rustc 1.62.0 (a8314ef7d 2022-06-27)
) in the good old cmd terminal.
It renders like this:
C:\code\rust\tables>cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.41s
Running `target\debug\tables.exe`
+-------+-------+
|||
+===============+
|||
+-------+-------+
Expected behavior
I expect contents to render. The same code renders fine on my Mac. And it works on Windows Terminal and cmd.exe on Windows 10.
Code
Please add a code example of how the bug is triggered.
fn main() {
let mut table = comfy_table::Table::new();
table.set_header(vec!["Hello", "World"]);
table.add_row(vec!["Hej", "Dig"]);
println!("{table}");
}
Steps to reproduce the bug
- Create a table with two columns
- Add one row
- Render it to the console
- Wonder why it's empty :thinking:
Additional context
- Operating System: Windows 8, using the GNU toolchain not the default Microsoft one,
stable-x86_64-pc-windows-gnu
- comfy-table version: 6.0.0
This is an extremely weird bug :D
Could you do me a favor and try to run this example without default features:
comfy-table = { version = "6", default-features = false }
This disables the terminal specific logic and should probably resolve the issue.
In case it does fix this, I assume that this is due to incorrect styling instructions in windows environments. This would then be a bug in crossterm
, which is the library used by comfy-table
to handle stuff like this.
Could you try the following:
use crossterm::style::style;
fn main() {
let test = "This is a test";
let styled = style(test);
println!("{}", styled.to_string());
}
with this dependency:
crossterm = { version = "0.24" }
If that's the case, a fix for this is already on main.
It simply prevents the style
function of crossterm
being called, if there's no active styling, which is probably the best behavior anyway (even though it shouldn't change the behavior, as crossterm doesn't apply anything if there's nothing to apply. At least on Linux).
Ping @aclemmensen
Did you have some time to follow up on this :)? I'm really curious.
Closing due to inactivity