aboutsummaryrefslogtreecommitdiff
path: root/test/functional/terminal/buffer_spec.lua
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-12-07 19:14:56 +0800
committerGitHub <noreply@github.com>2023-12-07 19:14:56 +0800
commitaba954b662cc1223d11ac3dc99323b9ebf687085 (patch)
tree708302f034e2f5907ada07a995b75d4f6f6a7086 /test/functional/terminal/buffer_spec.lua
parent94c2703a0390fc7908faf5dcde80615ddf5e616e (diff)
downloadrneovim-aba954b662cc1223d11ac3dc99323b9ebf687085.tar.gz
rneovim-aba954b662cc1223d11ac3dc99323b9ebf687085.tar.bz2
rneovim-aba954b662cc1223d11ac3dc99323b9ebf687085.zip
fix(terminal): never propagate $COLORTERM from outer env (#26440)
If $COLORTERM is "truecolor" but the user sets 'notermguicolors', propagating $COLORTERM to :terminal usually doesn't work well.
Diffstat (limited to 'test/functional/terminal/buffer_spec.lua')
-rw-r--r--test/functional/terminal/buffer_spec.lua50
1 files changed, 50 insertions, 0 deletions
diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua
index 7a52ee2b13..ece09bca88 100644
--- a/test/functional/terminal/buffer_spec.lua
+++ b/test/functional/terminal/buffer_spec.lua
@@ -1,8 +1,10 @@
local helpers = require('test.functional.helpers')(after_each)
+local Screen = require('test.functional.ui.screen')
local thelpers = require('test.functional.terminal.helpers')
local assert_alive = helpers.assert_alive
local feed, clear, nvim = helpers.feed, helpers.clear, helpers.nvim
local poke_eventloop = helpers.poke_eventloop
+local nvim_prog = helpers.nvim_prog
local eval, feed_command, source = helpers.eval, helpers.feed_command, helpers.source
local pcall_err = helpers.pcall_err
local eq, neq = helpers.eq, helpers.neq
@@ -559,4 +561,52 @@ describe('termopen()', function()
eq("Vim:E11: Invalid in command-line window; <CR> executes, CTRL-C quits",
pcall_err(funcs.termopen, "bar"))
end)
+
+ 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
+ funcs.setenv('COLORTERM', 'wrongvalue')
+ end)
+
+ local function test_term_colorterm(expected, opts)
+ local screen = Screen.new(50, 4)
+ screen:attach()
+ funcs.termopen({
+ nvim_prog, '-u', 'NONE', '-i', 'NONE', '--headless',
+ '-c', 'echo $COLORTERM | quit',
+ }, opts)
+ screen:expect(([[
+ ^%s{MATCH:%%s+}|
+ [Process exited 0] |
+ |
+ |
+ ]]):format(expected))
+ end
+
+ describe("with 'notermguicolors'", function()
+ before_each(function()
+ command('set notermguicolors')
+ end)
+ it('is empty by default', function()
+ test_term_colorterm('')
+ end)
+ it('can be overridden', function()
+ test_term_colorterm('expectedvalue', { env = { COLORTERM = 'expectedvalue' } })
+ end)
+ end)
+
+ describe("with 'termguicolors'", function()
+ before_each(function()
+ command('set termguicolors')
+ end)
+ it('is "truecolor" by default', function()
+ test_term_colorterm('truecolor')
+ end)
+ it('can be overridden', function()
+ test_term_colorterm('expectedvalue', { env = { COLORTERM = 'expectedvalue' } })
+ end)
+ end)
+ end)
end)