terminal icon indicating copy to clipboard operation
terminal copied to clipboard

ITU/ODA colors with a zero color space don't work

Open j4james opened this issue 1 month ago • 1 comments

Windows Terminal version

1.24.2812.0

Windows build number

10.0.19045.5371

Other Software

No response

Steps to reproduce

Open a WSL shell and execute the following statements:

printf "\e[38:2::255:0:0mRED\e[m\n"
printf "\e[38:2:0:255:0:0mRED\e[m\n"

These are ITU T.416 RGB color sequences that set the foreground to bright red. The first case is using a default color space ID, and the second case has the color space ID set to zero, which should be the same thing.

Expected Behavior

In both cases I'd expect the text to be rendered with a red foreground color.

Actual Behavior

Only the first case is red - the second case is rendered with the default attributes.

Looking at the code, it seems this was somewhat by design. We're trying to detect cases where the sequence is incorrectly formatted, with the red component in the position of the color space ID. And the assumption is that it's better to ignore those sequences than produce a completely wrong color.

https://github.com/microsoft/terminal/blob/47018442cdb0fac323f9d68ff8e3156909882b9b/src/terminal/adapter/adaptDispatchGraphics.cpp#L128-L131

But if we're going to take that approach, I think the test probably needs to be stricter, because this is clearly not an incorrectly formatted colour - it has all the required components. And most other terminals that support ITU colors do render this case correctly (although we're not the only one that fails).

So maybe we should only be rejecting sequences that have a non-default color space, but also have a missing blue component?

j4james avatar Nov 10 '25 23:11 j4james

So maybe we should only be rejecting sequences that have a non-default color space, but also have a missing blue component?

That makes a lot of sense to me. Good catch, btw!

DHowett avatar Nov 10 '25 23:11 DHowett