diff options
Diffstat (limited to 'test/functional/terminal')
| -rw-r--r-- | test/functional/terminal/ex_terminal_spec.lua | 16 | ||||
| -rw-r--r-- | test/functional/terminal/highlight_spec.lua | 50 | ||||
| -rw-r--r-- | test/functional/terminal/scrollback_spec.lua | 12 | ||||
| -rw-r--r-- | test/functional/terminal/tui_spec.lua | 39 | ||||
| -rw-r--r-- | test/functional/terminal/window_split_tab_spec.lua | 8 |
5 files changed, 96 insertions, 29 deletions
diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua index dbee9bdb49..f3849709e3 100644 --- a/test/functional/terminal/ex_terminal_spec.lua +++ b/test/functional/terminal/ex_terminal_spec.lua @@ -99,6 +99,22 @@ describe(':terminal', function() eq(3, #jumps) end) + it(':stopinsert RPC request exits terminal-mode #7807', function() + command(':terminal') + feed('i[tui] insert-mode') + eq({ blocking=false, mode='t' }, nvim('get_mode')) + command('stopinsert') + eq({ blocking=false, mode='n' }, nvim('get_mode')) + end) + + it(':stopinsert in normal mode doesn\'t break insert mode #9889', function() + command(':terminal') + eq({ blocking=false, mode='n' }, nvim('get_mode')) + command(':stopinsert') + eq({ blocking=false, mode='n' }, nvim('get_mode')) + feed('a') + eq({ blocking=false, mode='t' }, nvim('get_mode')) + end) end) describe(':terminal (with fake shell)', function() diff --git a/test/functional/terminal/highlight_spec.lua b/test/functional/terminal/highlight_spec.lua index 9579e0ea0b..48fedd5927 100644 --- a/test/functional/terminal/highlight_spec.lua +++ b/test/functional/terminal/highlight_spec.lua @@ -3,9 +3,12 @@ local Screen = require('test.functional.ui.screen') local thelpers = require('test.functional.terminal.helpers') local feed, clear, nvim = helpers.feed, helpers.clear, helpers.nvim local nvim_dir, command = helpers.nvim_dir, helpers.command +local nvim_prog_abs = helpers.nvim_prog_abs local eq, eval = helpers.eq, helpers.eval +local funcs = helpers.funcs +local nvim_set = helpers.nvim_set -describe(':terminal window highlighting', function() +describe(':terminal highlight', function() local screen before_each(function() @@ -112,8 +115,51 @@ describe(':terminal window highlighting', function() end) end) +it(':terminal highlight has lower precedence than editor #9964', function() + clear() + local screen = Screen.new(30, 4) + screen:set_default_attr_ids({ + -- "Normal" highlight emitted by the child nvim process. + N_child = {foreground = tonumber('0x4040ff'), background = tonumber('0xffff40')}, + -- "Search" highlight emitted by the child nvim process. + S_child = {background = tonumber('0xffff40'), italic = true, foreground = tonumber('0x4040ff')}, + -- "Search" highlight in the parent nvim process. + S = {background = Screen.colors.Green, italic = true, foreground = Screen.colors.Red}, + -- "Question" highlight in the parent nvim process. + Q = {background = tonumber('0xffff40'), bold = true, foreground = Screen.colors.SeaGreen4}, + }) + screen:attach({rgb=true}) + -- Child nvim process in :terminal (with cterm colors). + funcs.termopen({ + nvim_prog_abs(), '-n', '-u', 'NORC', '-i', 'NONE', '--cmd', nvim_set, + '+hi Normal ctermfg=Blue ctermbg=Yellow', + '+norm! ichild nvim', + '+norm! oline 2', + }) + screen:expect([[ + {N_child:^child nvim }| + {N_child:line 2 }| + {N_child: }| + | + ]]) + command('hi Search gui=italic guifg=Red guibg=Green cterm=italic ctermfg=Red ctermbg=Green') + feed('/nvim<cr>') + screen:expect([[ + {N_child:child }{S:^nvim}{N_child: }| + {N_child:line 2 }| + {N_child: }| + /nvim | + ]]) + command('syntax keyword Question line') + screen:expect([[ + {N_child:child }{S:^nvim}{N_child: }| + {Q:line}{N_child: 2 }| + {N_child: }| + /nvim | + ]]) +end) -describe('terminal window highlighting with custom palette', function() +describe(':terminal highlight with custom palette', function() local screen before_each(function() diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua index 75bb89a1ab..544325e746 100644 --- a/test/functional/terminal/scrollback_spec.lua +++ b/test/functional/terminal/scrollback_spec.lua @@ -142,15 +142,15 @@ describe(':terminal scrollback', function() describe('and height decreased by 1', function() if helpers.pending_win32(pending) then return end local function will_hide_top_line() - feed([[<C-\><C-N>:]]) -- Go to cmdline-mode, so cursor is at bottom. + feed([[<C-\><C-N>]]) screen:try_resize(screen._width - 2, screen._height - 1) screen:expect([[ line2 | line3 | line4 | rows: 5, cols: 28 | - {2: } | - :^ | + {2:^ } | + | ]]) end @@ -166,11 +166,11 @@ describe(':terminal scrollback', function() screen:expect([[ rows: 5, cols: 28 | rows: 3, cols: 26 | - {2: } | - :^ | + {2:^ } | + | ]]) eq(8, curbuf('line_count')) - feed([[<C-\><C-N>3k]]) + feed([[3k]]) screen:expect([[ ^line4 | rows: 5, cols: 28 | diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua index a0adb45630..56d6f68b7a 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -1,8 +1,7 @@ -- TUI acceptance tests. -- Uses :terminal as a way to send keys and assert screen state. -local global_helpers = require('test.helpers') -local uname = global_helpers.uname local helpers = require('test.functional.helpers')(after_each) +local uname = helpers.uname local thelpers = require('test.functional.terminal.helpers') local Screen = require('test.functional.ui.screen') local eq = helpers.eq @@ -255,14 +254,14 @@ describe('TUI', function() ]]) end) - it('shows up in nvim_list_uis', function() + it('is included in nvim_list_uis()', function() feed_data(':echo map(nvim_list_uis(), {k,v -> sort(items(filter(v, {k,v -> k[:3] !=# "ext_" })))})\013') screen:expect([=[ | {4:~ }| {5: }| - [[['height', 6], ['rgb', v:false], ['width', 50]]]| - | + [[['height', 6], ['override', v:false], ['rgb', v:| + false], ['width', 50]]] | {10:Press ENTER or type command to continue}{1: } | {3:-- TERMINAL --} | ]=]) @@ -839,8 +838,7 @@ describe('TUI background color', function() it("triggers OptionSet event on terminal-response", function() feed_data('\027:autocmd OptionSet background echo "did OptionSet, yay!"\n') - -- The child Nvim is running asynchronously; wait for it to register the - -- OptionSet handler. + -- Wait for the child Nvim to register the OptionSet handler. feed_data('\027:autocmd OptionSet\n') screen:expect({any='--- Autocommands ---'}) @@ -860,16 +858,23 @@ describe('TUI background color', function() local function assert_bg(color, bg) it('handles '..color..' as '..bg, function() - feed_data('\027]11;rgb:'..color..'\007:echo &background\n') - screen:expect(string.format([[ - {1: } | - {4:~ }| - {4:~ }| - {4:~ }| - {5:[No Name] 0,0-1 All}| - %-5s | - {3:-- TERMINAL --} | - ]], bg)) + feed_data('\027]11;rgb:'..color..'\007') + -- Retry until the terminal response is handled. + retry(100, nil, function() + feed_data(':echo &background\n') + screen:expect({ + timeout=40, + grid=string.format([[ + {1: } | + {4:~ }| + {4:~ }| + {4:~ }| + {5:[No Name] 0,0-1 All}| + %-5s | + {3:-- TERMINAL --} | + ]], bg) + }) + end) end) end diff --git a/test/functional/terminal/window_split_tab_spec.lua b/test/functional/terminal/window_split_tab_spec.lua index c0ce656bb1..ad70b3d14f 100644 --- a/test/functional/terminal/window_split_tab_spec.lua +++ b/test/functional/terminal/window_split_tab_spec.lua @@ -69,7 +69,7 @@ describe(':terminal', function() end) it('forwards resize request to the program', function() - feed([[<C-\><C-N>G:]]) -- Go to cmdline-mode, so cursor is at bottom. + feed([[<C-\><C-N>G]]) local w1, h1 = screen._width - 3, screen._height - 2 local w2, h2 = w1 - 6, h1 - 3 @@ -92,16 +92,16 @@ describe(':terminal', function() | | | + ^ | | - :^ | ]]) screen:try_resize(w2, h2) screen:expect([[ tty ready | rows: 7, cols: 47 | rows: 4, cols: 41 | - {2: } | - :^ | + {2:^ } | + | ]]) end) end) |