aboutsummaryrefslogtreecommitdiff
path: root/test/functional/terminal/highlight_spec.lua
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2025-02-05 23:09:29 +0000
committerJosh Rahm <joshuarahm@gmail.com>2025-02-05 23:09:29 +0000
commitd5f194ce780c95821a855aca3c19426576d28ae0 (patch)
treed45f461b19f9118ad2bb1f440a7a08973ad18832 /test/functional/terminal/highlight_spec.lua
parentc5d770d311841ea5230426cc4c868e8db27300a8 (diff)
parent44740e561fc93afe3ebecfd3618bda2d2abeafb0 (diff)
downloadrneovim-d5f194ce780c95821a855aca3c19426576d28ae0.tar.gz
rneovim-d5f194ce780c95821a855aca3c19426576d28ae0.tar.bz2
rneovim-d5f194ce780c95821a855aca3c19426576d28ae0.zip
Merge remote-tracking branch 'upstream/master' into mix_20240309HEADrahm
Diffstat (limited to 'test/functional/terminal/highlight_spec.lua')
-rw-r--r--test/functional/terminal/highlight_spec.lua105
1 files changed, 59 insertions, 46 deletions
diff --git a/test/functional/terminal/highlight_spec.lua b/test/functional/terminal/highlight_spec.lua
index 7822a27b93..0afbd010f7 100644
--- a/test/functional/terminal/highlight_spec.lua
+++ b/test/functional/terminal/highlight_spec.lua
@@ -6,7 +6,6 @@ local tt = require('test.functional.testterm')
local feed, clear = n.feed, n.clear
local api = n.api
local testprg, command = n.testprg, n.command
-local nvim_prog_abs = n.nvim_prog_abs
local fn = n.fn
local nvim_set = n.nvim_set
local is_os = t.is_os
@@ -33,11 +32,11 @@ describe(':terminal highlight', function()
[12] = { bold = true, underdouble = true },
[13] = { italic = true, undercurl = true },
})
- command(("enew | call termopen(['%s'])"):format(testprg('tty-test')))
+ command(("enew | call jobstart(['%s'], {'term':v:true})"):format(testprg('tty-test')))
feed('i')
screen:expect([[
tty ready |
- {10: } |
+ ^ |
|*4
{5:-- TERMINAL --} |
]])
@@ -61,7 +60,7 @@ describe(':terminal highlight', function()
skip(is_os('win'))
screen:expect(sub([[
tty ready |
- {NUM:text}text{10: } |
+ {NUM:text}text^ |
|*4
{5:-- TERMINAL --} |
]]))
@@ -84,7 +83,7 @@ describe(':terminal highlight', function()
line6 |
line7 |
line8 |
- {10: } |
+ ^ |
{5:-- TERMINAL --} |
]])
feed('<c-\\><c-n>gg')
@@ -150,8 +149,8 @@ it(':terminal highlight has lower precedence than editor #9964', function()
},
})
-- Child nvim process in :terminal (with cterm colors).
- fn.termopen({
- nvim_prog_abs(),
+ fn.jobstart({
+ n.nvim_prog,
'-n',
'-u',
'NORC',
@@ -163,6 +162,7 @@ it(':terminal highlight has lower precedence than editor #9964', function()
'+norm! ichild nvim',
'+norm! oline 2',
}, {
+ term = true,
env = {
VIMRUNTIME = os.getenv('VIMRUNTIME'),
},
@@ -195,12 +195,12 @@ it('CursorLine and CursorColumn work in :terminal buffer in Normal mode', functi
local screen = Screen.new(50, 7)
screen:set_default_attr_ids({
[1] = { background = Screen.colors.Grey90 }, -- CursorLine, CursorColumn
- [2] = { reverse = true }, -- TermCursor
+ [2] = { reverse = true },
[3] = { bold = true }, -- ModeMsg
[4] = { background = Screen.colors.Grey90, reverse = true },
[5] = { background = Screen.colors.Red },
})
- command(("enew | call termopen(['%s'])"):format(testprg('tty-test')))
+ command(("enew | call jobstart(['%s'], {'term':v:true})"):format(testprg('tty-test')))
screen:expect([[
^tty ready |
|*6
@@ -234,7 +234,7 @@ it('CursorLine and CursorColumn work in :terminal buffer in Normal mode', functi
foobar foobar foobar foobar foobar foobar foobar f|
oobar foobar foobar foobar foobar foobar foobar fo|
obar foobar foobar foobar foobar foobar foobar foo|
- bar foobar{2: } |
+ bar foobar^ |
{3:-- TERMINAL --} |
]])
-- Leaving terminal mode restores old values.
@@ -248,46 +248,60 @@ it('CursorLine and CursorColumn work in :terminal buffer in Normal mode', functi
{1:bar fooba^r }|
|
]])
- -- CursorLine and CursorColumn are combined with TermCursorNC.
- command('highlight TermCursorNC gui=reverse')
+
+ -- Skip the rest of these tests on Windows #31587
+ if is_os('win') then
+ return
+ end
+
+ -- CursorLine and CursorColumn are combined with terminal colors.
+ tt.set_reverse()
+ tt.feed_data(' foobar')
+ tt.clear_attrs()
screen:expect([[
tty ready{1: } |
foobar f{1:o}obar foobar foobar foobar foobar foobar |
foobar fo{1:o}bar foobar foobar foobar foobar foobar f|
oobar foo{1:b}ar foobar foobar foobar foobar foobar fo|
obar foob{1:a}r foobar foobar foobar foobar foobar foo|
- {1:bar fooba^r}{4: }{1: }|
+ {1:bar fooba^r}{4: foobar}{1: }|
|
]])
- feed('2gg11|')
+ feed('2gg15|')
screen:expect([[
- tty ready {1: } |
- {1: foobar fo^obar foobar foobar foobar foobar foobar }|
- foobar foo{1:b}ar foobar foobar foobar foobar foobar f|
- oobar foob{1:a}r foobar foobar foobar foobar foobar fo|
- obar fooba{1:r} foobar foobar foobar foobar foobar foo|
- bar foobar{4: } |
+ tty ready {1: } |
+ {1: foobar foobar^ foobar foobar foobar foobar foobar }|
+ foobar foobar {1:f}oobar foobar foobar foobar foobar f|
+ oobar foobar f{1:o}obar foobar foobar foobar foobar fo|
+ obar foobar fo{1:o}bar foobar foobar foobar foobar foo|
+ bar foobar{2: foo}{4:b}{2:ar} |
|
]])
- -- TermCursorNC has higher precedence.
- command('highlight TermCursorNC gui=NONE guibg=Red')
+
+ -- Set bg color to red
+ tt.feed_csi('48;2;255:0:0m')
+ tt.feed_data(' foobar')
+ tt.clear_attrs()
+ feed('2gg20|')
+
+ -- Terminal color has higher precedence
screen:expect([[
- tty ready {1: } |
- {1: foobar fo^obar foobar foobar foobar foobar foobar }|
- foobar foo{1:b}ar foobar foobar foobar foobar foobar f|
- oobar foob{1:a}r foobar foobar foobar foobar foobar fo|
- obar fooba{1:r} foobar foobar foobar foobar foobar foo|
- bar foobar{5: } |
+ tty ready {1: } |
+ {1: foobar foobar foob^ar foobar foobar foobar foobar }|
+ foobar foobar fooba{1:r} foobar foobar foobar foobar f|
+ oobar foobar foobar{1: }foobar foobar foobar foobar fo|
+ obar foobar foobar {1:f}oobar foobar foobar foobar foo|
+ bar foobar{2: foobar}{5: foobar} |
|
]])
feed('G$')
screen:expect([[
- tty ready{1: } |
- foobar f{1:o}obar foobar foobar foobar foobar foobar |
- foobar fo{1:o}bar foobar foobar foobar foobar foobar f|
- oobar foo{1:b}ar foobar foobar foobar foobar foobar fo|
- obar foob{1:a}r foobar foobar foobar foobar foobar foo|
- {1:bar fooba^r}{5: }{1: }|
+ tty ready {1: } |
+ foobar foobar foobar f{1:o}obar foobar foobar foobar |
+ foobar foobar foobar fo{1:o}bar foobar foobar foobar f|
+ oobar foobar foobar foo{1:b}ar foobar foobar foobar fo|
+ obar foobar foobar foob{1:a}r foobar foobar foobar foo|
+ {1:bar foobar}{4: foobar}{5: fooba^r}{1: }|
|
]])
end)
@@ -300,18 +314,17 @@ describe(':terminal highlight forwarding', function()
screen = Screen.new(50, 7)
screen:set_rgb_cterm(true)
screen:set_default_attr_ids({
- [1] = { { reverse = true }, { reverse = true } },
- [2] = { { bold = true }, { bold = true } },
- [3] = { { fg_indexed = true, foreground = tonumber('0xe0e000') }, { foreground = 3 } },
- [4] = { { foreground = tonumber('0xff8000') }, {} },
+ [1] = { { bold = true }, { bold = true } },
+ [2] = { { fg_indexed = true, foreground = tonumber('0xe0e000') }, { foreground = 3 } },
+ [3] = { { foreground = tonumber('0xff8000') }, {} },
})
- command(("enew | call termopen(['%s'])"):format(testprg('tty-test')))
+ command(("enew | call jobstart(['%s'], {'term':v:true})"):format(testprg('tty-test')))
feed('i')
screen:expect([[
tty ready |
- {1: } |
+ ^ |
|*4
- {2:-- TERMINAL --} |
+ {1:-- TERMINAL --} |
]])
end)
@@ -326,9 +339,9 @@ describe(':terminal highlight forwarding', function()
screen:expect {
grid = [[
tty ready |
- {3:text}{4:color}text{1: } |
+ {2:text}{3:color}text^ |
|*4
- {2:-- TERMINAL --} |
+ {1:-- TERMINAL --} |
]],
}
end)
@@ -351,11 +364,11 @@ describe(':terminal highlight with custom palette', function()
[9] = { bold = true },
})
api.nvim_set_var('terminal_color_3', '#123456')
- command(("enew | call termopen(['%s'])"):format(testprg('tty-test')))
+ command(("enew | call jobstart(['%s'], {'term':v:true})"):format(testprg('tty-test')))
feed('i')
screen:expect([[
tty ready |
- {7: } |
+ ^ |
|*4
{9:-- TERMINAL --} |
]])
@@ -369,7 +382,7 @@ describe(':terminal highlight with custom palette', function()
tt.feed_data('text')
screen:expect([[
tty ready |
- {1:text}text{7: } |
+ {1:text}text^ |
|*4
{9:-- TERMINAL --} |
]])