diff options
Diffstat (limited to 'test/functional/terminal')
-rw-r--r-- | test/functional/terminal/altscreen_spec.lua | 16 | ||||
-rw-r--r-- | test/functional/terminal/api_spec.lua | 70 | ||||
-rw-r--r-- | test/functional/terminal/buffer_spec.lua | 51 | ||||
-rw-r--r-- | test/functional/terminal/cursor_spec.lua | 35 | ||||
-rw-r--r-- | test/functional/terminal/edit_spec.lua | 6 | ||||
-rw-r--r-- | test/functional/terminal/ex_terminal_spec.lua | 104 | ||||
-rw-r--r-- | test/functional/terminal/helpers.lua | 22 | ||||
-rw-r--r-- | test/functional/terminal/highlight_spec.lua | 157 | ||||
-rw-r--r-- | test/functional/terminal/mouse_spec.lua | 92 | ||||
-rw-r--r-- | test/functional/terminal/scrollback_spec.lua | 34 | ||||
-rw-r--r-- | test/functional/terminal/tui_spec.lua | 251 | ||||
-rw-r--r-- | test/functional/terminal/window_spec.lua | 7 | ||||
-rw-r--r-- | test/functional/terminal/window_split_tab_spec.lua | 135 |
13 files changed, 627 insertions, 353 deletions
diff --git a/test/functional/terminal/altscreen_spec.lua b/test/functional/terminal/altscreen_spec.lua index d9d96b25f9..4526037808 100644 --- a/test/functional/terminal/altscreen_spec.lua +++ b/test/functional/terminal/altscreen_spec.lua @@ -1,4 +1,4 @@ -local helpers = require('test.functional.helpers') +local helpers = require('test.functional.helpers')(after_each) local thelpers = require('test.functional.terminal.helpers') local clear, eq, curbuf = helpers.clear, helpers.eq, helpers.curbuf local feed = helpers.feed @@ -6,6 +6,8 @@ local feed_data = thelpers.feed_data local enter_altscreen = thelpers.enter_altscreen local exit_altscreen = thelpers.exit_altscreen +if helpers.pending_win32(pending) then return end + describe('terminal altscreen', function() local screen @@ -21,7 +23,7 @@ describe('terminal altscreen', function() line7 | line8 | {1: } | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) enter_altscreen() screen:expect([[ @@ -31,7 +33,7 @@ describe('terminal altscreen', function() | | {1: } | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) eq(10, curbuf('line_count')) end) @@ -60,7 +62,7 @@ describe('terminal altscreen', function() line7 | line8 | {1: } | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) feed('<c-\\><c-n>gg') screen:expect([[ @@ -86,7 +88,7 @@ describe('terminal altscreen', function() line15 | line16 | {1: } | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) end) @@ -116,7 +118,7 @@ describe('terminal altscreen', function() | rows: 4, cols: 50 | {1: } | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) end @@ -149,7 +151,7 @@ describe('terminal altscreen', function() line5 | line6 | line7 | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) end) end) diff --git a/test/functional/terminal/api_spec.lua b/test/functional/terminal/api_spec.lua new file mode 100644 index 0000000000..045bdb0749 --- /dev/null +++ b/test/functional/terminal/api_spec.lua @@ -0,0 +1,70 @@ +local helpers = require('test.functional.helpers')(after_each) +local child_session = require('test.functional.terminal.helpers') +local ok = helpers.ok + +if helpers.pending_win32(pending) then return end + +describe('api', function() + local screen + local socket_name = "Xtest_functional_api.sock" + + before_each(function() + helpers.clear() + os.remove(socket_name) + screen = child_session.screen_setup(0, '["'..helpers.nvim_prog + ..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile"]') + end) + after_each(function() + os.remove(socket_name) + end) + + it("qa! RPC request during insert-mode", function() + -- Start the socket from the child nvim. + child_session.feed_data(":echo serverstart('"..socket_name.."')\n") + + -- Wait for socket creation. + screen:expect([[ + {1: } | + {4:~ }| + {4:~ }| + {4:~ }| + {5:[No Name] }| + ]]..socket_name..[[ | + {3:-- TERMINAL --} | + ]]) + + local socket_session1 = helpers.connect(socket_name) + local socket_session2 = helpers.connect(socket_name) + + child_session.feed_data("i[tui] insert-mode") + -- Wait for stdin to be processed. + screen:expect([[ + [tui] insert-mode{1: } | + {4:~ }| + {4:~ }| + {4:~ }| + {5:[No Name] [+] }| + {3:-- INSERT --} | + {3:-- TERMINAL --} | + ]]) + + ok(socket_session1:request("nvim_ui_attach", 42, 6, {rgb=true})) + ok(socket_session2:request("nvim_ui_attach", 25, 30, {rgb=true})) + + socket_session1:notify("nvim_input", "\n[socket 1] this is more than 25 columns") + socket_session2:notify("nvim_input", "\n[socket 2] input") + + screen:expect([[ + [tui] insert-mode | + [socket 1] this is more t{4: }| + han 25 columns {4: }| + [socket 2] input{1: } {4: }| + {5:[No Name] [+] }| + {3:-- INSERT --} | + {3:-- TERMINAL --} | + ]]) + + socket_session1:request("nvim_command", "qa!") + end) +end) + diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua index cefb603a7e..cecd67d7fa 100644 --- a/test/functional/terminal/buffer_spec.lua +++ b/test/functional/terminal/buffer_spec.lua @@ -1,10 +1,11 @@ -local helpers = require('test.functional.helpers') +local helpers = require('test.functional.helpers')(after_each) local thelpers = require('test.functional.terminal.helpers') local feed, clear, nvim = helpers.feed, helpers.clear, helpers.nvim local wait = helpers.wait local eval, execute, source = helpers.eval, helpers.execute, helpers.source local eq, neq = helpers.eq, helpers.neq +if helpers.pending_win32(pending) then return end describe('terminal buffer', function() local screen @@ -21,11 +22,11 @@ describe('terminal buffer', function() feed('<c-\\><c-n>:set bufhidden=wipe<cr>:enew<cr>') screen:expect([[ ^ | - ~ | - ~ | - ~ | - ~ | - ~ | + {4:~ }| + {4:~ }| + {4:~ }| + {4:~ }| + {4:~ }| :enew | ]]) end) @@ -34,11 +35,11 @@ describe('terminal buffer', function() feed(':bnext:l<esc>') screen:expect([[ ^ | - ~ | - ~ | - ~ | - ~ | - ~ | + {4:~ }| + {4:~ }| + {4:~ }| + {4:~ }| + {4:~ }| | ]]) end) @@ -78,7 +79,7 @@ describe('terminal buffer', function() | | ^ | - E21: Cannot make changes, 'modifiable' is off | + {8:E21: Cannot make changes, 'modifiable' is off} | ]]) end) @@ -138,21 +139,21 @@ describe('terminal buffer', function() feed('<c-\\><c-n>:bd!<cr>') screen:expect([[ ^ | - ~ | - ~ | - ~ | - ~ | - ~ | + {4:~ }| + {4:~ }| + {4:~ }| + {4:~ }| + {4:~ }| :bd! | ]]) execute('bnext') screen:expect([[ ^ | - ~ | - ~ | - ~ | - ~ | - ~ | + {4:~ }| + {4:~ }| + {4:~ }| + {4:~ }| + {4:~ }| :bnext | ]]) end) @@ -166,7 +167,7 @@ describe('terminal buffer', function() local tbuf = eval('bufnr("%")') source([[ - function! SplitWindow() + function! SplitWindow(id, data, event) new call feedkeys("iabc\<Esc>") endfunction @@ -180,8 +181,8 @@ describe('terminal buffer', function() -- We should be in a new buffer now. screen:expect([[ ab^c | - ~ | - ========== | + {4:~ }| + {5:========== }| rows: 2, cols: 50 | {2: } | {1:========== }| diff --git a/test/functional/terminal/cursor_spec.lua b/test/functional/terminal/cursor_spec.lua index c15da2f760..1953022a7a 100644 --- a/test/functional/terminal/cursor_spec.lua +++ b/test/functional/terminal/cursor_spec.lua @@ -1,4 +1,4 @@ -local helpers = require('test.functional.helpers') +local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local thelpers = require('test.functional.terminal.helpers') local feed, clear, nvim = helpers.feed, helpers.clear, helpers.nvim @@ -6,6 +6,7 @@ local nvim_dir, execute = helpers.nvim_dir, helpers.execute local hide_cursor = thelpers.hide_cursor local show_cursor = thelpers.show_cursor +if helpers.pending_win32(pending) then return end describe('terminal cursor', function() local screen @@ -25,7 +26,7 @@ describe('terminal cursor', function() | | | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) end) @@ -49,12 +50,12 @@ describe('terminal cursor', function() it('is positioned correctly when unfocused', function() screen:expect([[ - 1 tty ready | - 2 {2: } | - 3 | - 4 | - 5 | - 6 ^ | + {7: 1 }tty ready | + {7: 2 }{2: } | + {7: 3 } | + {7: 4 } | + {7: 5 } | + {7: 6 }^ | :set number | ]]) end) @@ -83,7 +84,7 @@ describe('terminal cursor', function() | | | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) show_cursor() screen:expect([[ @@ -93,7 +94,7 @@ describe('terminal cursor', function() | | | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) -- same for when the terminal is unfocused feed('<c-\\><c-n>') @@ -132,16 +133,10 @@ describe('cursor with customized highlighting', function() screen = Screen.new(50, 7) screen:set_default_attr_ids({ [1] = {foreground = 45, background = 46}, - [2] = {foreground = 55, background = 56} - }) - screen:set_default_attr_ignore({ - [1] = {bold = true}, - [2] = {foreground = 12}, - [3] = {bold = true, reverse = true}, - [5] = {background = 11}, - [6] = {foreground = 130}, + [2] = {foreground = 55, background = 56}, + [3] = {bold = true}, }) - screen:attach(false) + screen:attach({rgb=false}) execute('call termopen(["'..nvim_dir..'/tty-test"]) | startinsert') end) @@ -153,7 +148,7 @@ describe('cursor with customized highlighting', function() | | | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) feed('<c-\\><c-n>') screen:expect([[ diff --git a/test/functional/terminal/edit_spec.lua b/test/functional/terminal/edit_spec.lua index dcc4a54610..8edcfa56b7 100644 --- a/test/functional/terminal/edit_spec.lua +++ b/test/functional/terminal/edit_spec.lua @@ -1,4 +1,4 @@ -local helpers = require('test.functional.helpers') +local helpers = require('test.functional.helpers')(after_each) local screen = require('test.functional.ui.screen') local curbufmeths = helpers.curbufmeths @@ -12,7 +12,7 @@ local eq = helpers.eq describe(':edit term://*', function() local get_screen = function(columns, lines) local scr = screen.new(columns, lines) - scr:attach(false) + scr:attach({rgb=false}) return scr end @@ -45,7 +45,7 @@ describe(':edit term://*', function() command('edit term://foobar') local bufcontents = {} local winheight = curwinmeths.get_height() - -- I have no idea why there is + 4 needed. But otherwise it works fine with + -- I have no idea why there is + 4 needed. But otherwise it works fine with -- different scrollbacks. local shift = -4 local buf_cont_start = rep_size - 1 - sb - winheight - shift diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua index d89092ff27..7c391db18c 100644 --- a/test/functional/terminal/ex_terminal_spec.lua +++ b/test/functional/terminal/ex_terminal_spec.lua @@ -1,23 +1,67 @@ -local helpers = require('test.functional.helpers') +local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear, wait, nvim = helpers.clear, helpers.wait, helpers.nvim local nvim_dir, source, eq = helpers.nvim_dir, helpers.source, helpers.eq local execute, eval = helpers.execute, helpers.eval +if helpers.pending_win32(pending) then return end + describe(':terminal', function() local screen before_each(function() clear() screen = Screen.new(50, 4) - screen:attach(false) + screen:attach({rgb=false}) + end) + + it("does not interrupt Press-ENTER prompt #2748", function() + -- Ensure that :messages shows Press-ENTER. + source([[ + echomsg "msg1" + echomsg "msg2" + ]]) + -- Invoke a command that emits frequent terminal activity. + execute([[terminal while true; do echo X; done]]) + helpers.feed([[<C-\><C-N>]]) + screen:expect([[ + X | + X | + ^X | + | + ]]) + helpers.sleep(10) -- Let some terminal activity happen. + execute("messages") + screen:expect([[ + X | + msg1 | + msg2 | + Press ENTER or type command to continue^ | + ]]) + end) + +end) + +describe(':terminal (with fake shell)', function() + local screen + + before_each(function() + clear() + screen = Screen.new(50, 4) + screen:attach({rgb=false}) + -- shell-test.c is a fake shell that prints its arguments and exits. nvim('set_option', 'shell', nvim_dir..'/shell-test') nvim('set_option', 'shellcmdflag', 'EXE') - end) + -- Invokes `:terminal {cmd}` using a fake shell (shell-test.c) which prints + -- the {cmd} and exits immediately . + local function terminal_with_fake_shell(cmd) + execute("terminal "..(cmd and cmd or "")) + end + it('with no argument, acts like termopen()', function() - execute('terminal') + terminal_with_fake_shell() wait() screen:expect([[ ready $ | @@ -28,7 +72,7 @@ describe(':terminal', function() end) it('executes a given command through the shell', function() - execute('terminal echo hi') + terminal_with_fake_shell('echo hi') wait() screen:expect([[ ready $ echo hi | @@ -39,7 +83,7 @@ describe(':terminal', function() end) it('allows quotes and slashes', function() - execute([[terminal echo 'hello' \ "world"]]) + terminal_with_fake_shell([[echo 'hello' \ "world"]]) wait() screen:expect([[ ready $ echo 'hello' \ "world" | @@ -56,4 +100,52 @@ describe(':terminal', function() -- Verify that BufNew actually fired (else the test is invalid). eq('foo', eval('&shell')) end) + + it('ignores writes if the backing stream closes', function() + terminal_with_fake_shell() + helpers.feed('iiXXXXXXX') + wait() + -- Race: Though the shell exited (and streams were closed by SIGCHLD + -- handler), :terminal cleanup is pending on the main-loop. + -- This write should be ignored (not crash, #5445). + helpers.feed('iiYYYYYYY') + eq(2, eval("1+1")) -- Still alive? + end) + + it('works with findfile()', function() + execute('terminal') + eq('term://', string.match(eval('bufname("%")'), "^term://")) + eq('scripts/shadacat.py', eval('findfile("scripts/shadacat.py", ".")')) + end) + + it('works with :find', function() + terminal_with_fake_shell() + wait() + screen:expect([[ + ready $ | + [Process exited 0] | + | + -- TERMINAL -- | + ]]) + eq('term://', string.match(eval('bufname("%")'), "^term://")) + helpers.feed([[<C-\><C-N>]]) + execute([[find */shadacat.py]]) + eq('scripts/shadacat.py', eval('bufname("%")')) + end) + + it('works with gf', function() + terminal_with_fake_shell([[echo "scripts/shadacat.py"]]) + wait() + screen:expect([[ + ready $ echo "scripts/shadacat.py" | + | + [Process exited 0] | + -- TERMINAL -- | + ]]) + helpers.feed([[<C-\><C-N>]]) + eq('term://', string.match(eval('bufname("%")'), "^term://")) + helpers.feed([[ggf"lgf]]) + eq('scripts/shadacat.py', eval('bufname("%")')) + end) + end) diff --git a/test/functional/terminal/helpers.lua b/test/functional/terminal/helpers.lua index a32ae650d6..ae5e6d4b1f 100644 --- a/test/functional/terminal/helpers.lua +++ b/test/functional/terminal/helpers.lua @@ -1,4 +1,4 @@ -local helpers = require('test.functional.helpers') +local helpers = require('test.functional.helpers')(nil) local Screen = require('test.functional.ui.screen') local nvim_dir = helpers.nvim_dir local execute, nvim, wait = helpers.execute, helpers.nvim, helpers.wait @@ -44,17 +44,17 @@ local function screen_setup(extra_height, command) screen:set_default_attr_ids({ [1] = {reverse = true}, -- focused cursor [2] = {background = 11}, -- unfocused cursor - }) - screen:set_default_attr_ignore({ - [1] = {bold = true}, - [2] = {foreground = 12}, - [3] = {bold = true, reverse = true}, - [5] = {background = 11}, - [6] = {foreground = 130}, - [7] = {foreground = 15, background = 1}, -- error message + [3] = {bold = true}, + [4] = {foreground = 12}, + [5] = {bold = true, reverse = true}, + [6] = {background = 11}, + [7] = {foreground = 130}, + [8] = {foreground = 15, background = 1}, -- error message + [9] = {foreground = 4}, + [10] = {foreground = 2}, -- "Press ENTER" in embedded :terminal session. }) - screen:attach(false) + screen:attach({rgb=false}) -- tty-test puts the terminal into raw mode and echoes all input. tests are -- done by feeding it with terminfo codes to control the display and -- verifying output with screen:expect. @@ -76,7 +76,7 @@ local function screen_setup(extra_height, command) table.insert(expected, empty_line) end - table.insert(expected, '-- TERMINAL -- ') + table.insert(expected, '{3:-- TERMINAL --} ') screen:expect(table.concat(expected, '\n')) else wait() diff --git a/test/functional/terminal/highlight_spec.lua b/test/functional/terminal/highlight_spec.lua index 97875c5147..0fe463401e 100644 --- a/test/functional/terminal/highlight_spec.lua +++ b/test/functional/terminal/highlight_spec.lua @@ -1,10 +1,11 @@ -local helpers = require('test.functional.helpers') +local helpers = require('test.functional.helpers')(after_each) 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, execute = helpers.nvim_dir, helpers.execute local eq, eval = helpers.eq, helpers.eval +if helpers.pending_win32(pending) then return end describe('terminal window highlighting', function() local screen @@ -16,36 +17,35 @@ describe('terminal window highlighting', function() [1] = {foreground = 45}, [2] = {background = 46}, [3] = {foreground = 45, background = 46}, - [4] = {bold = true, italic = true, underline = true} - }) - screen:set_default_attr_ignore({ - [1] = {bold = true}, - [2] = {foreground = 12}, - [3] = {bold = true, reverse = true}, - [5] = {background = 11}, - [6] = {foreground = 130}, - [7] = {reverse = true}, + [4] = {bold = true, italic = true, underline = true}, + [5] = {bold = true}, + [6] = {foreground = 12}, + [7] = {bold = true, reverse = true}, [8] = {background = 11}, + [9] = {foreground = 130}, + [10] = {reverse = true}, + [11] = {background = 11}, }) - screen:attach(false) + screen:attach({rgb=false}) execute('enew | call termopen(["'..nvim_dir..'/tty-test"]) | startinsert') screen:expect([[ tty ready | + {10: } | | | | | - | - -- TERMINAL -- | + {5:-- TERMINAL --} | ]]) end) local function descr(title, attr_num, set_attrs_fn) local function sub(s) - return s:gsub('NUM', attr_num) + local str = s:gsub('NUM', attr_num) + return str end - describe(title, function() + describe(title, function() before_each(function() set_attrs_fn() thelpers.feed_data('text') @@ -54,16 +54,15 @@ describe('terminal window highlighting', function() end) local function pass_attrs() - local s = sub([[ + screen:expect(sub([[ tty ready | - {NUM:text}text | + {NUM:text}text{10: } | | | | | - -- TERMINAL -- | - ]]) - screen:expect(s) + {5:-- TERMINAL --} | + ]])) end it('will pass the corresponding attributes', pass_attrs) @@ -82,11 +81,11 @@ describe('terminal window highlighting', function() line6 | line7 | line8 | - | - -- TERMINAL -- | + {10: } | + {5:-- TERMINAL --} | ]]) feed('<c-\\><c-n>gg') - local s = sub([[ + screen:expect(sub([[ ^tty ready | {NUM:text}textline1 | line2 | @@ -94,8 +93,7 @@ describe('terminal window highlighting', function() line4 | line5 | | - ]]) - screen:expect(s) + ]])) end) end) end @@ -121,28 +119,26 @@ describe('terminal window highlighting with custom palette', function() clear() screen = Screen.new(50, 7) screen:set_default_attr_ids({ - [1] = {foreground = 1193046, special = Screen.colors.Black} - }) - screen:set_default_attr_ignore({ - [1] = {bold = true}, + [1] = {foreground = 1193046, special = Screen.colors.Black}, [2] = {foreground = 12}, [3] = {bold = true, reverse = true}, [5] = {background = 11}, [6] = {foreground = 130}, [7] = {reverse = true}, [8] = {background = 11}, + [9] = {bold = true}, }) - screen:attach(true) + screen:attach({rgb=true}) nvim('set_var', 'terminal_color_3', '#123456') execute('enew | call termopen(["'..nvim_dir..'/tty-test"]) | startinsert') screen:expect([[ tty ready | + {7: } | | | | | - | - -- TERMINAL -- | + {9:-- TERMINAL --} | ]]) end) @@ -153,36 +149,111 @@ describe('terminal window highlighting with custom palette', function() thelpers.feed_data('text') screen:expect([[ tty ready | - {1:text}text | + {1:text}text{7: } | | | | | - -- TERMINAL -- | + {9:-- TERMINAL --} | ]]) end) end) describe('synIDattr()', function() local screen - before_each(function() clear() screen = Screen.new(50, 7) - execute('highlight Normal ctermfg=1 guifg=#ff0000') + execute('highlight Normal ctermfg=252 guifg=#ff0000 guibg=Black') + -- Salmon #fa8072 Maroon #800000 + execute('highlight Keyword ctermfg=79 guifg=Salmon guisp=Maroon') + end) + + it('returns cterm-color if RGB-capable UI is _not_ attached', function() + eq('252', eval('synIDattr(hlID("Normal"), "fg")')) + eq('252', eval('synIDattr(hlID("Normal"), "fg#")')) + eq('', eval('synIDattr(hlID("Normal"), "bg")')) + eq('', eval('synIDattr(hlID("Normal"), "bg#")')) + eq('79', eval('synIDattr(hlID("Keyword"), "fg")')) + eq('79', eval('synIDattr(hlID("Keyword"), "fg#")')) + eq('', eval('synIDattr(hlID("Keyword"), "sp")')) + eq('', eval('synIDattr(hlID("Keyword"), "sp#")')) end) - after_each(function() - screen:detach() + it('returns gui-color if "gui" arg is passed', function() + eq('Black', eval('synIDattr(hlID("Normal"), "bg", "gui")')) + eq('Maroon', eval('synIDattr(hlID("Keyword"), "sp", "gui")')) end) - it('returns RGB number if GUI', function() - screen:attach(true) - eq('#ff0000', eval('synIDattr(hlID("Normal"), "fg")')) + it('returns gui-color if RGB-capable UI is attached', function() + screen:attach({rgb=true}) + eq('#ff0000', eval('synIDattr(hlID("Normal"), "fg")')) + eq('Black', eval('synIDattr(hlID("Normal"), "bg")')) + eq('Salmon', eval('synIDattr(hlID("Keyword"), "fg")')) + eq('Maroon', eval('synIDattr(hlID("Keyword"), "sp")')) + end) + + it('returns #RRGGBB value for fg#/bg#/sp#', function() + screen:attach({rgb=true}) + eq('#ff0000', eval('synIDattr(hlID("Normal"), "fg#")')) + eq('#000000', eval('synIDattr(hlID("Normal"), "bg#")')) + eq('#fa8072', eval('synIDattr(hlID("Keyword"), "fg#")')) + eq('#800000', eval('synIDattr(hlID("Keyword"), "sp#")')) end) it('returns color number if non-GUI', function() - screen:attach(false) - eq('1', eval('synIDattr(hlID("Normal"), "fg")')) + screen:attach({rgb=false}) + eq('252', eval('synIDattr(hlID("Normal"), "fg")')) + eq('79', eval('synIDattr(hlID("Keyword"), "fg")')) + end) +end) + +describe('fg/bg special colors', function() + local screen + before_each(function() + clear() + screen = Screen.new(50, 7) + execute('highlight Normal ctermfg=145 ctermbg=16 guifg=#ff0000 guibg=Black') + execute('highlight Visual ctermfg=bg ctermbg=fg guifg=bg guibg=fg guisp=bg') + end) + + it('resolve to "Normal" values', function() + eq(eval('synIDattr(hlID("Normal"), "bg")'), + eval('synIDattr(hlID("Visual"), "fg")')) + eq(eval('synIDattr(hlID("Normal"), "bg#")'), + eval('synIDattr(hlID("Visual"), "fg#")')) + eq(eval('synIDattr(hlID("Normal"), "fg")'), + eval('synIDattr(hlID("Visual"), "bg")')) + eq(eval('synIDattr(hlID("Normal"), "fg#")'), + eval('synIDattr(hlID("Visual"), "bg#")')) + eq('bg', eval('synIDattr(hlID("Visual"), "fg", "gui")')) + eq('bg', eval('synIDattr(hlID("Visual"), "fg#", "gui")')) + eq('fg', eval('synIDattr(hlID("Visual"), "bg", "gui")')) + eq('fg', eval('synIDattr(hlID("Visual"), "bg#", "gui")')) + eq('bg', eval('synIDattr(hlID("Visual"), "sp", "gui")')) + eq('bg', eval('synIDattr(hlID("Visual"), "sp#", "gui")')) + end) + + it('resolve to "Normal" values in RGB-capable UI', function() + screen:attach({rgb=true}) + eq('bg', eval('synIDattr(hlID("Visual"), "fg")')) + eq(eval('synIDattr(hlID("Normal"), "bg#")'), + eval('synIDattr(hlID("Visual"), "fg#")')) + eq('fg', eval('synIDattr(hlID("Visual"), "bg")')) + eq(eval('synIDattr(hlID("Normal"), "fg#")'), + eval('synIDattr(hlID("Visual"), "bg#")')) + eq('bg', eval('synIDattr(hlID("Visual"), "sp")')) + eq(eval('synIDattr(hlID("Normal"), "bg#")'), + eval('synIDattr(hlID("Visual"), "sp#")')) + end) + + it('resolve after the "Normal" group is modified', function() + screen:attach({rgb=true}) + local new_guibg = '#282c34' + local new_guifg = '#abb2bf' + execute('highlight Normal guifg='..new_guifg..' guibg='..new_guibg) + eq(new_guibg, eval('synIDattr(hlID("Visual"), "fg#")')) + eq(new_guifg, eval('synIDattr(hlID("Visual"), "bg#")')) + eq(new_guibg, eval('synIDattr(hlID("Visual"), "sp#")')) end) end) diff --git a/test/functional/terminal/mouse_spec.lua b/test/functional/terminal/mouse_spec.lua index c4bd3c2663..ecb0b2beb0 100644 --- a/test/functional/terminal/mouse_spec.lua +++ b/test/functional/terminal/mouse_spec.lua @@ -1,9 +1,11 @@ -local helpers = require('test.functional.helpers') +local helpers = require('test.functional.helpers')(after_each) local thelpers = require('test.functional.terminal.helpers') local clear = helpers.clear local feed, nvim = helpers.feed, helpers.nvim local feed_data = thelpers.feed_data +if helpers.pending_win32(pending) then return end + describe('terminal mouse', function() local screen @@ -27,7 +29,7 @@ describe('terminal mouse', function() line29 | line30 | {1: } | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) end) @@ -74,7 +76,7 @@ describe('terminal mouse', function() line30 | mouse enabled | {1: } | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) end) @@ -87,7 +89,7 @@ describe('terminal mouse', function() line30 | mouse enabled | "#{1: } | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) end) @@ -100,7 +102,7 @@ describe('terminal mouse', function() line30 | mouse enabled | `!!{1: } | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) end) end) @@ -112,86 +114,86 @@ describe('terminal mouse', function() line28 |line28 | line29 |line29 | line30 |line30 | - rows: 5, cols: 24 |rows: 5, cols: 24 | + rows: 5, cols: 25 |rows: 5, cols: 25 | {2:^ } |{2: } | ========== ========== | | ]]) feed(':enew | set number<cr>') screen:expect([[ - 1 ^ |line28 | - ~ |line29 | - ~ |line30 | - ~ |rows: 5, cols: 24 | - ~ |{2: } | + {7: 1 }^ |line28 | + {4:~ }|line29 | + {4:~ }|line30 | + {4:~ }|rows: 5, cols: 25 | + {4:~ }|{2: } | ========== ========== | :enew | set number | ]]) feed('30iline\n<esc>') screen:expect([[ - 27 line |line28 | - 28 line |line29 | - 29 line |line30 | - 30 line |rows: 5, cols: 24 | - 31 ^ |{2: } | + {7: 27 }line |line28 | + {7: 28 }line |line29 | + {7: 29 }line |line30 | + {7: 30 }line |rows: 5, cols: 25 | + {7: 31 }^ |{2: } | ========== ========== | | ]]) feed('<c-w>li') screen:expect([[ - 27 line |line28 | - 28 line |line29 | - 29 line |line30 | - 30 line |rows: 5, cols: 24 | - 31 |{1: } | + {7: 27 }line |line29 | + {7: 28 }line |line30 | + {7: 29 }line |rows: 5, cols: 25 | + {7: 30 }line |rows: 5, cols: 24 | + {7: 31 } |{1: } | ========== ========== | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) -- enabling mouse won't affect interaction with other windows thelpers.enable_mouse() thelpers.feed_data('mouse enabled\n') screen:expect([[ - 27 line |line29 | - 28 line |line30 | - 29 line |rows: 5, cols: 24 | - 30 line |mouse enabled | - 31 |{1: } | + {7: 27 }line |line30 | + {7: 28 }line |rows: 5, cols: 25 | + {7: 29 }line |rows: 5, cols: 24 | + {7: 30 }line |mouse enabled | + {7: 31 } |{1: } | ========== ========== | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) end) it('wont lose focus if another window is scrolled', function() feed('<MouseDown><0,0><MouseDown><0,0>') screen:expect([[ - 21 line |line29 | - 22 line |line30 | - 23 line |rows: 5, cols: 24 | - 24 line |mouse enabled | - 25 line |{1: } | + {7: 21 }line |line30 | + {7: 22 }line |rows: 5, cols: 25 | + {7: 23 }line |rows: 5, cols: 24 | + {7: 24 }line |mouse enabled | + {7: 25 }line |{1: } | ========== ========== | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) feed('<S-MouseUp><0,0>') screen:expect([[ - 26 line |line29 | - 27 line |line30 | - 28 line |rows: 5, cols: 24 | - 29 line |mouse enabled | - 30 line |{1: } | + {7: 26 }line |line30 | + {7: 27 }line |rows: 5, cols: 25 | + {7: 28 }line |rows: 5, cols: 24 | + {7: 29 }line |mouse enabled | + {7: 30 }line |{1: } | ========== ========== | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) end) it('will lose focus if another window is clicked', function() feed('<LeftMouse><5,1>') screen:expect([[ - 27 line |line29 | - 28 l^ine |line30 | - 29 line |rows: 5, cols: 24 | - 30 line |mouse enabled | - 31 |{2: } | + {7: 27 }line |line30 | + {7: 28 }l^ine |rows: 5, cols: 25 | + {7: 29 }line |rows: 5, cols: 24 | + {7: 30 }line |mouse enabled | + {7: 31 } |{2: } | ========== ========== | | ]]) diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua index 4b56698520..d60819af65 100644 --- a/test/functional/terminal/scrollback_spec.lua +++ b/test/functional/terminal/scrollback_spec.lua @@ -1,11 +1,13 @@ local Screen = require('test.functional.ui.screen') -local helpers = require('test.functional.helpers') +local helpers = require('test.functional.helpers')(after_each) local thelpers = require('test.functional.terminal.helpers') local clear, eq, curbuf = helpers.clear, helpers.eq, helpers.curbuf local feed, nvim_dir, execute = helpers.feed, helpers.nvim_dir, helpers.execute local wait = helpers.wait local feed_data = thelpers.feed_data +if helpers.pending_win32(pending) then return end + describe('terminal scrollback', function() local screen @@ -33,7 +35,7 @@ describe('terminal scrollback', function() line29 | line30 | {1: } | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) end) @@ -61,7 +63,7 @@ describe('terminal scrollback', function() line3 | line4 | {1: } | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) end) @@ -76,7 +78,7 @@ describe('terminal scrollback', function() line4 | line5 | {1: } | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) eq(7, curbuf('line_count')) end) @@ -92,7 +94,7 @@ describe('terminal scrollback', function() line6 | line7 | line8{1: } | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) feed('<c-\\><c-n>6k') @@ -141,7 +143,7 @@ describe('terminal scrollback', function() line4 | rows: 5, cols: 50 | {1: } | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) end @@ -158,7 +160,7 @@ describe('terminal scrollback', function() rows: 5, cols: 50 | rows: 3, cols: 50 | {1: } | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) eq(8, curbuf('line_count')) feed('<c-\\><c-n>3k') @@ -185,7 +187,7 @@ describe('terminal scrollback', function() rows: 4, cols: 50 | {1: } | | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) eq(4, curbuf('line_count')) end @@ -203,7 +205,7 @@ describe('terminal scrollback', function() rows: 4, cols: 50 | rows: 3, cols: 50 | {1: } | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) eq(4, curbuf('line_count')) feed('<c-\\><c-n>gg') @@ -218,7 +220,7 @@ describe('terminal scrollback', function() rows: 4, cols: 50 | rows: 3, cols: 50 | {1: } | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) end) end) @@ -235,14 +237,14 @@ describe('terminal scrollback', function() line3 | line4 | {1: } | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) screen:try_resize(screen._width, screen._height - 3) screen:expect([[ line4 | rows: 3, cols: 50 | {1: } | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) eq(7, curbuf('line_count')) end) @@ -255,7 +257,7 @@ describe('terminal scrollback', function() rows: 3, cols: 50 | rows: 4, cols: 50 | {1: } | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) end @@ -277,7 +279,7 @@ describe('terminal scrollback', function() rows: 4, cols: 50 | rows: 7, cols: 50 | {1: } | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) eq(9, curbuf('line_count')) feed('<c-\\><c-n>gg') @@ -315,7 +317,7 @@ describe('terminal scrollback', function() rows: 11, cols: 50 | {1: } | | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) -- since there's an empty line after the cursor, the buffer line -- count equals the terminal screen height @@ -331,7 +333,7 @@ describe('terminal prints more lines than the screen height and exits', function it('will push extra lines to scrollback', function() clear() local screen = Screen.new(50, 7) - screen:attach(false) + screen:attach({rgb=false}) execute('call termopen(["'..nvim_dir..'/tty-test", "10"]) | startinsert') wait() screen:expect([[ diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua index 364ca327a4..60f989d701 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -1,11 +1,13 @@ -- Some sanity checks for the TUI using the builtin terminal emulator -- as a simple way to send keys and assert screen state. -local helpers = require('test.functional.helpers') +local helpers = require('test.functional.helpers')(after_each) local thelpers = require('test.functional.terminal.helpers') local feed = thelpers.feed_data local execute = helpers.execute local nvim_dir = helpers.nvim_dir +if helpers.pending_win32(pending) then return end + describe('tui', function() local screen @@ -17,12 +19,12 @@ describe('tui', function() screen.timeout = 60000 screen:expect([[ {1: } | - ~ | - ~ | - ~ | - [No Name] | + {4:~ }| + {4:~ }| + {4:~ }| + {5:[No Name] }| | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) end) @@ -36,20 +38,20 @@ describe('tui', function() abc | test1 | test2{1: } | - ~ | - [No Name] [+] | - -- INSERT -- | - -- TERMINAL -- | + {4:~ }| + {5:[No Name] [+] }| + {3:-- INSERT --} | + {3:-- TERMINAL --} | ]]) feed('\027') screen:expect([[ abc | test1 | test{1:2} | - ~ | - [No Name] [+] | + {4:~ }| + {5:[No Name] [+] }| | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) end) @@ -64,9 +66,9 @@ describe('tui', function() alt-k | alt-l | {1: } | - [No Name] [+] | + {5:[No Name] [+] }| | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) feed('gg') screen:expect([[ @@ -74,9 +76,9 @@ describe('tui', function() alt-f | alt-g | alt-h | - [No Name] [+] | + {5:[No Name] [+] }| | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) end) @@ -90,12 +92,12 @@ describe('tui', function() feed('i\027j') screen:expect([[ j{1: } | - ~ | - ~ | - ~ | - [No Name] [+] | - -- INSERT -- | - -- TERMINAL -- | + {4:~ }| + {4:~ }| + {4:~ }| + {5:[No Name] [+] }| + {3:-- INSERT --} | + {3:-- TERMINAL --} | ]]) end) @@ -105,46 +107,46 @@ describe('tui', function() feed('\022\022') -- ctrl+v feed('\022\013') -- ctrl+m screen:expect([[ - {3:^G^V^M}{1: } | - ~ | - ~ | - ~ | - [No Name] [+] | - -- INSERT -- | - -- TERMINAL -- | - ]], {[1] = {reverse = true}, [2] = {background = 11}, [3] = {foreground = 4}}) + {9:^G^V^M}{1: } | + {4:~ }| + {4:~ }| + {4:~ }| + {5:[No Name] [+] }| + {3:-- INSERT --} | + {3:-- TERMINAL --} | + ]]) end) it('automatically sends <Paste> for bracketed paste sequences', function() feed('i\027[200~') screen:expect([[ {1: } | - ~ | - ~ | - ~ | - [No Name] | - -- INSERT (paste) -- | - -- TERMINAL -- | + {4:~ }| + {4:~ }| + {4:~ }| + {5:[No Name] }| + {3:-- INSERT (paste) --} | + {3:-- TERMINAL --} | ]]) feed('pasted from terminal') screen:expect([[ pasted from terminal{1: } | - ~ | - ~ | - ~ | - [No Name] [+] | - -- INSERT (paste) -- | - -- TERMINAL -- | + {4:~ }| + {4:~ }| + {4:~ }| + {5:[No Name] [+] }| + {3:-- INSERT (paste) --} | + {3:-- TERMINAL --} | ]]) feed('\027[201~') screen:expect([[ pasted from terminal{1: } | - ~ | - ~ | - ~ | - [No Name] [+] | - -- INSERT -- | - -- TERMINAL -- | + {4:~ }| + {4:~ }| + {4:~ }| + {5:[No Name] [+] }| + {3:-- INSERT --} | + {3:-- TERMINAL --} | ]]) end) @@ -160,9 +162,9 @@ describe('tui', function() item 2998 | item 2999 | item 3000{1: } | - [No Name] [+] 3000,10 Bot| - -- INSERT -- | - -- TERMINAL -- | + {5:[No Name] [+] 3000,10 Bot}| + {3:-- INSERT --} | + {3:-- TERMINAL --} | ]]) end) end) @@ -176,17 +178,15 @@ describe('tui with non-tty file descriptors', function() it('can handle pipes as stdout and stderr', function() local screen = thelpers.screen_setup(0, '"'..helpers.nvim_prog..' -u NONE -i NONE --cmd \'set noswapfile\' --cmd \'normal iabc\' > /dev/null 2>&1 && cat testF && rm testF"') - screen:set_default_attr_ids({}) - screen:set_default_attr_ignore(true) feed(':w testF\n:q\n') screen:expect([[ :w testF | :q | abc | | - [Process exited 0] | + [Process exited 0]{1: } | | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) end) end) @@ -205,23 +205,23 @@ describe('tui focus event handling', function() feed('\027[I') screen:expect([[ {1: } | - ~ | - ~ | - ~ | - [No Name] | + {4:~ }| + {4:~ }| + {4:~ }| + {5:[No Name] }| gained | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) feed('\027[O') screen:expect([[ {1: } | - ~ | - ~ | - ~ | - [No Name] | + {4:~ }| + {4:~ }| + {4:~ }| + {5:[No Name] }| lost | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) end) @@ -231,22 +231,22 @@ describe('tui focus event handling', function() feed('\027[I') screen:expect([[ {1: } | - ~ | - ~ | - ~ | - [No Name] | + {4:~ }| + {4:~ }| + {4:~ }| + {5:[No Name] }| gained | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) feed('\027[O') screen:expect([[ {1: } | - ~ | - ~ | - ~ | - [No Name] | + {4:~ }| + {4:~ }| + {4:~ }| + {5:[No Name] }| lost | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) end) @@ -255,22 +255,22 @@ describe('tui focus event handling', function() feed('\027[I') screen:expect([[ | - ~ | - ~ | - ~ | - [No Name] | + {4:~ }| + {4:~ }| + {4:~ }| + {5:[No Name] }| g{1:a}ined | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) feed('\027[O') screen:expect([[ | - ~ | - ~ | - ~ | - [No Name] | + {4:~ }| + {4:~ }| + {4:~ }| + {5:[No Name] }| l{1:o}st | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) end) @@ -287,7 +287,7 @@ describe('tui focus event handling', function() | | gained | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) feed('\027[O') screen:expect([[ @@ -297,7 +297,82 @@ describe('tui focus event handling', function() | | lost | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) end) end) + +-- These tests require `thelpers` because --headless/--embed +-- does not initialize the TUI. +describe("tui 't_Co' (terminal colors)", function() + local screen + local is_linux = (helpers.eval("system('uname') =~? 'linux'") == 1) + + local function assert_term_colors(term, colorterm, maxcolors) + helpers.clear({env={TERM=term}, args={}}) + -- This is ugly because :term/termopen() forces TERM=xterm-256color. + -- TODO: Revisit this after jobstart/termopen accept `env` dict. + screen = thelpers.screen_setup(0, string.format( + [=[['sh', '-c', 'LANG=C TERM=%s %s %s -u NONE -i NONE --cmd "silent set noswapfile"']]=], + term, + (colorterm ~= nil and "COLORTERM="..colorterm or ""), + helpers.nvim_prog)) + + thelpers.feed_data(":echo &t_Co\n") + local tline + if maxcolors == 8 then + tline = "~ " + else + tline = "{4:~ }" + end + screen:expect(string.format([[ + {1: } | + %s| + %s| + %s| + {5:[No Name] }| + %-3s | + {3:-- TERMINAL --} | + ]], tline, tline, tline, tostring(maxcolors and maxcolors or ""))) + end + + it("unknown TERM sets empty 't_Co'", function() + assert_term_colors("yet-another-term", nil, nil) + end) + + it("unknown TERM with COLORTERM=screen-256color uses 256 colors", function() + assert_term_colors("yet-another-term", "screen-256color", 256) + end) + + it("TERM=linux uses 8 colors", function() + if is_linux then + assert_term_colors("linux", nil, 8) + else + pending() + end + end) + + it("TERM=screen uses 8 colors", function() + if is_linux then + assert_term_colors("screen", nil, 8) + else + pending() + end + end) + + it("TERM=screen COLORTERM=screen-256color uses 256 colors", function() + assert_term_colors("screen", "screen-256color", 256) + end) + + it("TERM=yet-another-term COLORTERM=screen-256color uses 256 colors", function() + assert_term_colors("screen", "screen-256color", 256) + end) + + it("TERM=xterm uses 256 colors", function() + assert_term_colors("xterm", nil, 256) + end) + + it("TERM=xterm-256color uses 256 colors", function() + assert_term_colors("xterm-256color", nil, 256) + end) +end) diff --git a/test/functional/terminal/window_spec.lua b/test/functional/terminal/window_spec.lua index 6c236ed868..eb7a67a1a6 100644 --- a/test/functional/terminal/window_spec.lua +++ b/test/functional/terminal/window_spec.lua @@ -1,8 +1,9 @@ -local helpers = require('test.functional.helpers') +local helpers = require('test.functional.helpers')(after_each) local thelpers = require('test.functional.terminal.helpers') local feed, clear = helpers.feed, helpers.clear local wait = helpers.wait +if helpers.pending_win32(pending) then return end describe('terminal window', function() local screen @@ -35,7 +36,7 @@ describe('terminal window', function() | | | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) end) end) @@ -51,7 +52,7 @@ describe('terminal window', function() line3 | line4 | {1: } | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) end) diff --git a/test/functional/terminal/window_split_tab_spec.lua b/test/functional/terminal/window_split_tab_spec.lua index 727eba2717..6951b84a69 100644 --- a/test/functional/terminal/window_split_tab_spec.lua +++ b/test/functional/terminal/window_split_tab_spec.lua @@ -1,7 +1,10 @@ -local helpers = require('test.functional.helpers') +local helpers = require('test.functional.helpers')(after_each) local thelpers = require('test.functional.terminal.helpers') local clear = helpers.clear local feed, nvim = helpers.feed, helpers.nvim +local execute = helpers.execute + +if helpers.pending_win32(pending) then return end describe('terminal', function() local screen @@ -21,6 +24,49 @@ describe('terminal', function() screen:detach() end) + it('resets its size when entering terminal window', function() + feed('<c-\\><c-n>') + execute('2split') + screen:expect([[ + tty ready | + ^rows: 2, cols: 50 | + ========== | + tty ready | + rows: 2, cols: 50 | + {2: } | + {4:~ }| + {4:~ }| + ========== | + | + ]]) + execute('wincmd p') + screen:expect([[ + tty ready | + rows: 2, cols: 50 | + ========== | + tty ready | + rows: 2, cols: 50 | + rows: 5, cols: 50 | + {2: } | + ^ | + ========== | + :wincmd p | + ]]) + execute('wincmd p') + screen:expect([[ + rows: 5, cols: 50 | + ^rows: 2, cols: 50 | + ========== | + rows: 5, cols: 50 | + rows: 2, cols: 50 | + {2: } | + {4:~ }| + {4:~ }| + ========== | + :wincmd p | + ]]) + end) + describe('when the screen is resized', function() it('will forward a resize request to the program', function() screen:try_resize(screen._width + 3, screen._height + 5) @@ -39,7 +85,7 @@ describe('terminal', function() | | | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) screen:try_resize(screen._width - 6, screen._height - 10) screen:expect([[ @@ -47,91 +93,8 @@ describe('terminal', function() rows: 14, cols: 53 | rows: 4, cols: 47 | {1: } | - -- TERMINAL -- | - ]]) - end) - end) - - describe('split horizontally', function() - before_each(function() - nvim('command', 'sp') - end) - - local function reduce_height() - screen:expect([[ - tty ready | - rows: 3, cols: 50 | - {1: } | - ~ | - ========== | - tty ready | - rows: 3, cols: 50 | - {2: } | - ========== | - -- TERMINAL -- | + {3:-- TERMINAL --} | ]]) - end - - it('uses the minimum height of all window displaying it', reduce_height) - - describe('and then vertically', function() - before_each(function() - reduce_height() - nvim('command', 'vsp') - end) - - local function reduce_width() - screen:expect([[ - rows: 3, cols: 50 |rows: 3, cols: 50 | - rows: 3, cols: 24 |rows: 3, cols: 24 | - {1: } |{2: } | - ~ |~ | - ========== ========== | - rows: 3, cols: 50 | - rows: 3, cols: 24 | - {2: } | - ========== | - -- TERMINAL -- | - ]]) - feed('<c-\\><c-n>gg') - screen:expect([[ - ^tty ready |rows: 3, cols: 50 | - rows: 3, cols: 50 |rows: 3, cols: 24 | - rows: 3, cols: 24 |{2: } | - {2: } |~ | - ========== ========== | - rows: 3, cols: 50 | - rows: 3, cols: 24 | - {2: } | - ========== | - | - ]]) - end - - it('uses the minimum width of all window displaying it', reduce_width) - - describe('and then closes one of the vertical splits with q:', function() - before_each(function() - reduce_width() - nvim('command', 'q') - feed('<c-w>ja') - end) - - it('will restore the width', function() - screen:expect([[ - rows: 3, cols: 24 | - rows: 3, cols: 50 | - {2: } | - ~ | - ========== | - rows: 3, cols: 24 | - rows: 3, cols: 50 | - {1: } | - ========== | - -- TERMINAL -- | - ]]) - end) - end) end) end) end) |