spectre.console
spectre.console copied to clipboard
Using Wide Character compatibility renders double table columns in gnome-terminal
When using gnome-terminal, and have the option Ambiguous-width character set to Wide causes spectre.console to render all tables with the double amount of table columns (Setting the option to narrow fixes this issue though).

Reproducible in gnome-terminal by setting the following option:
Edit --> Preferences --> Compatibility --> Ambiguous-width character = Wide.

@AdmiringWorm Yeah, not sure what to do about something like this, to be honest. Is there an environment variable or something that this setting is reflected via? In that case, we might not use wcwidth when calculating character width and multiply the number of characters with 2. That would fix your problem. That is, if there is a way of detecting this.
Honestly, I got no idea if it is possible to detect it through an environment variable, I believe the only way to find out is to query gsettings (but I do not know what the settings name would be).
Best bet would probably to document the issue instead, maybe allow the settings to be overridden? Personally, I fixed the issue on my end by just setting the ambiguous-width character to narrow instead of wide, but that is something that would need to be done per user.
@AdmiringWorm Can you check what VTE_CJK_WIDTH environment variable is when "Ambiguous-width character" is set to Wide and Narrow?
@patriksvensson I just checked, it is undefined (or at least empty) both for Wide and for Narrow.
@AdmiringWorm Out of curiosity. If you set your terminal to have "Ambiguous-width character" is set to Wide, then launch the table example with VTE_CJK_WIDTH=1, VTE_CJK_WIDTH=0 and VTE_CJK_WIDTH=2, do you see any difference in the output?
@patriksvensson no, there is no difference in the output with either one of the values of the variable. All of them produces the same output (both using Wide and for Narrow compatibility set).
To check if it was something that changes that causes this, I traced back to the earliest version of spectre.console the showed the same symptoms.
I found that since v0.4.0 (the introduction of panels I believe), the same issue occurs.
I also compared all environment variables set between the Wide and Narrow compatibility layer, and unfortunately, there are no changes between them.
@AdmiringWorm I see. Sadly this has nothing really to do with Spectre.Console, it's the Gnome terminal which behaves in a way that's kind of unorthodox, so the best we can do is document the behavior if we can't detect it.
This might come up again for windows terminal, if https://github.com/microsoft/terminal/issues/153 is being implemented.