microsoft / microsoft/terminal

Vim in MS Terminal mistakes color of ctermfg=7

Open
#15,408 13 comments 0 reactions 0 assignees View on GitHub
Area-Server Issue-Docs Issue-Task Product-Conpty
Dominant language
C++
Stars
105k
Forks
9.6k
Avg merge
3d 17h
Merged PRs (30d)
29

Description

### Windows Terminal version

1.18.1241.0

### Windows build number

10.0.22621.1702

### Other Software

Vim 9.0.1472

### Steps to reproduce

I have the following colorscheme in MS Terminal:

```
{
"background": "#FAFAFA",
"black": "#383A42",
"blue": "#0184BC",
"brightBlack": "#4F525D",
"brightBlue": "#61AFEF",
"brightCyan": "#56B5C1",
"brightGreen": "#98C379",
"brightPurple": "#C577DD",
"brightRed": "#DF6C75",
"brightWhite": "#FAFAFA",
"brightYellow": "#E4C07A",
"cursorColor": "#383A42",
"cyan": "#0997B3",
"foreground": "#383A42",
"green": "#50A14F",
"name": "Yellowish",
"purple": "#A626A4",
"red": "#E45649",
"selectionBackground": "#61AFEF",
"white": "#FCF4DC",
"yellow": "#C18301"
}
```

With this colorscheme activated, run vim as follows.

```
vim --clean -c 'se ls=2 | hi StatusLine cterm=none ctermbg=8 ctermfg=7'
```

You'll see a statusline with black blacground, which is expected with `ctermbg=8`, and brightBlack foreground, whereas you should expect a white foreground with `ctermfg=7`.

### Expected Behavior

With help of colortool, I modified Console Host to have the same colorscheme as MS Terminal. Here is the .ini scheme for easy reproduction:

```
[info]
name = Custom
author = enan

[table]
DARK_BLACK = 56,58,66
DARK_BLUE = 1,132,188
DARK_GREEN = 80,161,79
DARK_CYAN = 9,151,179
DARK_RED = 228,86,73
DARK_MAGENTA = 166,38,164
DARK_YELLOW = 193,131,1
DARK_WHITE = 252,244,220
BRIGHT_BLACK = 79,82,93
BRIGHT_BLUE = 97,175,239
BRIGHT_GREEN = 152,195,121
BRIGHT_CYAN = 86,181,193
BRIGHT_RED = 223,108,117
BRIGHT_MAGENTA = 197,119,221
BRIGHT_YELLOW = 228,192,122
BRIGHT_WHITE = 250,250,250

[screen]
FOREGROUND = DARK_BLACK
BACKGROUND = BRIGHT_WHITE

[popup]
FOREGROUND = DARK_MAGENTA
BACKGROUND = DARK_WHITE
```

If you run the same command to start Vim, you'll now see a statusline with white foreground, which is what's expected from `ctermfg=7`.
![expected](https://github.com/microsoft/terminal/assets/32037751/f965ddab-15a1-471f-bb23-f27aa8b967bb)

### Actual Behavior

In MS Terminal, `ctermfg=7` does NOT use the white color defined in the color table/scheme.

![actual](https://github.com/microsoft/terminal/assets/32037751/7c52b17e-652c-476a-8dc5-22540be62b28)

In Console Host, `ctermfg=7` DOES use the white color defined in the color table/scheme.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with Vim 9.0.1472 and the provided Windows Terminal color scheme, then compare ctermfg=7 behavior with Console Host using the same palette. Trace terminal handling of the ctermfg and ctermbg values; done means the MS Terminal statusline uses the configured white color for ctermfg=7 while preserving the expected background.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
cli, desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.