Skip to content

Commit cde8ff6

Browse files
julio-bchrisbra
andcommitted
patch 9.1.1078: Terminal ansi colors off by one after tgc reset
Problem: Terminal ansi colors off by one after tgc reset Solution: Set the correct index for libvterm palette, revert parts in libvterm/src/pen.c that deviated from upstream (Julio B) fixes: #16568 closes: #16573 related: Vim patch v8.2.0804 Co-authored-by: Christian Brabandt <[email protected]> Signed-off-by: Julio B <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent f50d536 commit cde8ff6

File tree

5 files changed

+39
-4
lines changed

5 files changed

+39
-4
lines changed

src/libvterm/src/pen.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,7 @@ void vterm_state_set_default_colors(VTermState *state, const VTermColor *default
275275
void vterm_state_set_palette_color(VTermState *state, int index, const VTermColor *col)
276276
{
277277
if(index >= 0 && index < 16)
278-
{
279278
state->colors[index] = *col;
280-
state->colors[index].index = index + 1;
281-
}
282279
}
283280

284281
void vterm_state_convert_color_to_rgb(const VTermState *state, VTermColor *col)

src/term.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7494,7 +7494,7 @@ ansi_color2rgb(int nr, char_u *r, char_u *g, char_u *b, char_u *ansi_idx)
74947494
*r = ansi_table[nr][0];
74957495
*g = ansi_table[nr][1];
74967496
*b = ansi_table[nr][2];
7497-
*ansi_idx = nr;
7497+
*ansi_idx = nr + 1;
74987498
}
74997499
else
75007500
{
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
|$+0&#ffffff0| |p|r|i|n|t|f| |'|\|0|3@1|[|0|;|3|0|;|4|1|m|h|e|l@1|o| |w|o|r|l|d|\|0|3@1|[|0|m|\|n|'| @30
2+
|h+0#0000001#e000002|e|l@1|o| |w|o|r|l|d| +0#0000000#ffffff0@63
3+
|$| |p|r|i|n|t|f| |'|\|0|3@1|[|0|;|3|0|;|4|1|m|h|e|l@1|o| |w|o|r|l|d|\|0|3@1|[|0|m|\|n|'| @30
4+
|h+0#0000001#e000002|e|l@1|o| |w|o|r|l|d| +0#0000000#ffffff0@63
5+
|$| > @72
6+
|!+2#ffffff16#00e0003|s|h| |[|r|u|n@1|i|n|g|]| @43|1|,|1| @11|A|l@1
7+
| +0#0000000#ffffff0@74
8+
|~+0#4040ff13&| @73
9+
|~| @73
10+
|~| @73
11+
|[+1#0000000&|N|o| |N|a|m|e|]| @47|0|,|0|-|1| @9|A|l@1
12+
| +0&&@74

src/testdir/test_terminal.vim

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2149,6 +2149,30 @@ func Test_terminal_ansicolors_default()
21492149
exe buf . 'bwipe'
21502150
endfunc
21512151

2152+
func Test_terminal_ansicolors_default_reset_tgc()
2153+
CheckFeature termguicolors
2154+
CheckRunVimInTerminal
2155+
2156+
let $PS1="$ "
2157+
let buf = RunVimInTerminal('-c "term sh"', {'rows': 12})
2158+
call TermWait(buf)
2159+
" Wait for the shell to display a prompt
2160+
call WaitForAssert({-> assert_notequal('', term_getline(buf, 1))})
2161+
2162+
call term_sendkeys(buf, "printf '\\033[0;30;41mhello world\\033[0m\\n'\<CR>")
2163+
call WaitForAssert({-> assert_match('hello world', term_getline(buf, 2))})
2164+
call term_sendkeys(buf, "\<C-W>:set notgc\<CR>")
2165+
call term_sendkeys(buf, "printf '\\033[0;30;41mhello world\\033[0m\\n'\<CR>")
2166+
call WaitForAssert({-> assert_match('hello world', term_getline(buf, 4))})
2167+
2168+
call VerifyScreenDump(buf, 'Test_terminal_ansi_reset_tgc', {})
2169+
2170+
call term_sendkeys(buf, "exit\<CR>")
2171+
call TermWait(buf)
2172+
call StopVimInTerminal(buf)
2173+
unlet! $PS1
2174+
endfunc
2175+
21522176
let s:test_colors = [
21532177
\ '#616e64', '#0d0a79',
21542178
\ '#6d610d', '#0a7373',

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
1078,
707709
/**/
708710
1077,
709711
/**/

0 commit comments

Comments
 (0)