From 379e307148e08dd28cc98ea429ea3e686fd57966 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 4 Feb 2026 23:07:47 +0800 Subject: [PATCH] fix(terminal): also don't propagate $COLORTERM on Windows (#37699) The same reason in #26440 applies to Windows as well. --- src/nvim/eval/funcs.c | 4 +--- test/functional/terminal/buffer_spec.lua | 16 ++++++++-------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 349d99cfb5..9e5a3631fb 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -3327,8 +3327,8 @@ static const char *pty_ignored_env_vars[] = { "LINES", "TERMCAP", "COLORFGBG", - "COLORTERM", #endif + "COLORTERM", // Nvim-owned env vars. #6764 "VIM", "VIMRUNTIME", @@ -3376,12 +3376,10 @@ dict_T *create_environment(const dictitem_T *job_env, const bool clear_env, cons tv_dict_item_remove(env, dv); } } -#ifndef MSWIN // Set COLORTERM to "truecolor" if termguicolors is set if (p_tgc) { tv_dict_add_str(env, S_LEN("COLORTERM"), "truecolor"); } -#endif } } diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua index 88c1234302..fff0985051 100644 --- a/test/functional/terminal/buffer_spec.lua +++ b/test/functional/terminal/buffer_spec.lua @@ -1465,12 +1465,12 @@ describe('termopen() (deprecated alias to `jobstart(…,{term=true})`)', functio pcall_err(fn.termopen, 'bar') ) end) +end) + +describe('jobstart(…,{term=true})', function() + before_each(clear) describe('$COLORTERM value', function() - if skip(is_os('win'), 'Not applicable for Windows') then - return - end - before_each(function() -- Outer value should never be propagated to :terminal fn.setenv('COLORTERM', 'wrongvalue') @@ -1478,7 +1478,7 @@ describe('termopen() (deprecated alias to `jobstart(…,{term=true})`)', functio local function test_term_colorterm(expected, opts) local screen = Screen.new(50, 4) - fn.termopen({ + fn.jobstart({ nvim_prog, '-u', 'NONE', @@ -1487,7 +1487,7 @@ describe('termopen() (deprecated alias to `jobstart(…,{term=true})`)', functio '--headless', '-c', 'echo $COLORTERM | quit', - }, opts) + }, vim.tbl_extend('error', opts, { term = true })) screen:expect(([[ ^%s{MATCH:%%s+}| [Process exited 0] | @@ -1500,7 +1500,7 @@ describe('termopen() (deprecated alias to `jobstart(…,{term=true})`)', functio command('set notermguicolors') end) it('is empty by default', function() - test_term_colorterm('') + test_term_colorterm('', {}) end) it('can be overridden', function() test_term_colorterm('expectedvalue', { env = { COLORTERM = 'expectedvalue' } }) @@ -1512,7 +1512,7 @@ describe('termopen() (deprecated alias to `jobstart(…,{term=true})`)', functio command('set termguicolors') end) it('is "truecolor" by default', function() - test_term_colorterm('truecolor') + test_term_colorterm('truecolor', {}) end) it('can be overridden', function() test_term_colorterm('expectedvalue', { env = { COLORTERM = 'expectedvalue' } })