倉庫指標
- Star
- (35,764 star)
- PR 合併指標
- (平均合併 27天 19小時) (30 天內合併 24 個 PR)
描述
Windows Terminal version
1.16.10262.0
Windows build number
10.0.22000.0
Other Software
Inside WSL
Steps to reproduce
Running the following shell script:
T='●●●'
echo -e "\n 40m 41m 42m 43m\
44m 45m 46m 47m";
for FGs in ' m' ' 1m' ' 30m' '1;30m' ' 31m' '1;31m' ' 32m' \
'1;32m' ' 33m' '1;33m' ' 34m' '1;34m' ' 35m' '1;35m' \
' 36m' '1;36m' ' 37m' '1;37m';
do FG=${FGs// /}
echo -en " $FGs \033[$FG $T "
for BG in 40m 41m 42m 43m 44m 45m 46m 47m;
do echo -en "$EINS \033[$FG\033[$BG $T \033[0m";
done
Expected Behavior
Colors in VS Code terminal look like this (all combinations are readable):

Actual Behavior
In the Terminal app, things are worse:

I tried changing color schemes to no avail. Changing "Automatically adjust lightness of indistinguishable text" setting doesn't seem to have any effect either.
2023-03-06 UPDATE
Investigation Into VS Code Inner Workings
The contrast adjustment in VS Code terminal is set by terminal.integrated.minimumContrastRatio in settings. Mentioned in the docs a11y section: .../editor/accessibility#_terminal-accessibility - number between 1 and 21 with 4.5 as a default.
Actually, makes perfect sense it being an accessibility feature. With normal vision some bg/fg combinations are annoyingly hard to process. For a person with even mild colorblindness they could be completely unreadable.
The travel path for the minimum contrast value is:
- The settings value is sent to the
xterm.jsinstance that does the terminal rendering: vscode/.../xtermTerminal.ts:209; xterm.jsinvokes.ensureContrastRatioin xterm.js/.../DomRendererRowFactory.ts:338;- Which is implemented in Color.ts:259 and performs the adjustment based on
relativeLuminance(same file just above).
Most of the math is in there. I haven't found the place where background colors are adjusted (they are clearly darkened a bit).
Reasons to Reuse it for the Terminal App
- Consistency with the other MS app, people that use the setting in one app may look for the same setting in the other;
- Good for a11y (the current adjustment algorithm just isn't aggressive enough, since even with normal vision it's hardly noticeable).
Also, it would be really cool to have an option for the Terminal app to outright pick up VS Code settings (color scheme, minimum contrast, font family, font size, keybindings, etc...), but that is certainly a scope creep in the context of this issue.