From e946951f6aa46e9048ff56704714cef74a9e2eb4 Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Thu, 17 Jul 2025 03:54:22 +0200 Subject: [PATCH] test(tui_spec): flakiness, global highlight definitions #34958 --- test/functional/autocmd/focus_spec.lua | 45 +- test/functional/core/job_spec.lua | 18 +- test/functional/core/log_spec.lua | 2 +- test/functional/terminal/altscreen_spec.lua | 12 +- test/functional/terminal/api_spec.lua | 26 +- test/functional/terminal/buffer_spec.lua | 58 +- test/functional/terminal/channel_spec.lua | 73 +- test/functional/terminal/cursor_spec.lua | 550 +++---- test/functional/terminal/highlight_spec.lua | 109 +- test/functional/terminal/mouse_spec.lua | 246 +-- test/functional/terminal/scrollback_spec.lua | 83 +- test/functional/terminal/tui_spec.lua | 1536 ++++++++---------- test/functional/terminal/window_spec.lua | 110 +- test/functional/testterm.lua | 46 +- test/functional/ui/output_spec.lua | 64 +- 15 files changed, 1381 insertions(+), 1597 deletions(-) diff --git a/test/functional/autocmd/focus_spec.lua b/test/functional/autocmd/focus_spec.lua index 177e8997cf..ed5893f5a8 100644 --- a/test/functional/autocmd/focus_spec.lua +++ b/test/functional/autocmd/focus_spec.lua @@ -45,52 +45,37 @@ describe('autoread TUI FocusGained/FocusLost', function() local atime = os.time() - 10 vim.uv.fs_utime(path, atime, atime) - screen:expect { - grid = [[ + screen:expect([[ ^ | - {4:~ }|*3 - {5:[No Name] }| + {100:~ }|*3 + {3:[No Name] }| | - {3:-- TERMINAL --} | - ]], - } + {5:-- TERMINAL --} | + ]]) feed_command('edit ' .. path) - screen:expect { - grid = [[ + screen:expect([[ ^ | - {4:~ }|*3 - {5:xtest-foo }| + {100:~ }|*3 + {3:xtest-foo }| :edit xtest-foo | - {3:-- TERMINAL --} | - ]], - } + {5:-- TERMINAL --} | + ]]) feed_data('\027[O') feed_data('\027[O') - screen:expect { - grid = [[ - ^ | - {4:~ }|*3 - {5:xtest-foo }| - :edit xtest-foo | - {3:-- TERMINAL --} | - ]], - unchanged = true, - } + screen:expect_unchanged() t.write_file(path, expected_addition) feed_data('\027[I') - screen:expect { - grid = [[ + screen:expect([[ ^line 1 | line 2 | line 3 | line 4 | - {5:xtest-foo }| + {3:xtest-foo }| :edit xtest-foo | - {3:-- TERMINAL --} | - ]], - } + {5:-- TERMINAL --} | + ]]) end) end) diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua index 7f984b1e24..8caff81be4 100644 --- a/test/functional/core/job_spec.lua +++ b/test/functional/core/job_spec.lua @@ -961,16 +961,14 @@ describe('jobs', function() ]], timeout = 100, } - screen:expect { - grid = [[ + screen:expect([[ | {3: }| aaa | bbb | ccc | {6:Press ENTER or type command to continue}^ | - ]], - } + ]]) feed('') fn.jobstop(api.nvim_get_var('id')) end) @@ -993,16 +991,14 @@ describe('jobs', function() endfunc ]]) feed_command('call PrintAndPoll()') - screen:expect { - grid = [[ + screen:expect([[ | {3: }| aaa | bbb | ccc | {6:Press ENTER or type command to continue}^ | - ]], - } + ]]) feed('') fn.jobstop(api.nvim_get_var('id')) eq(0, busy) @@ -1260,9 +1256,9 @@ describe('jobs', function() screen:expect([[ ^ | ~ |*3 - {1:[No Name] 0,0-1 All}| + {2:[No Name] 0,0-1 All}| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed(':q') @@ -1273,7 +1269,7 @@ describe('jobs', function() | [Process exited 0]^ | |*4 - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end end) diff --git a/test/functional/core/log_spec.lua b/test/functional/core/log_spec.lua index 571bece833..07f91e5ba4 100644 --- a/test/functional/core/log_spec.lua +++ b/test/functional/core/log_spec.lua @@ -49,7 +49,7 @@ describe('log', function() ^ | ~ |*4 | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end diff --git a/test/functional/terminal/altscreen_spec.lua b/test/functional/terminal/altscreen_spec.lua index 839e37f541..631f7af7f8 100644 --- a/test/functional/terminal/altscreen_spec.lua +++ b/test/functional/terminal/altscreen_spec.lua @@ -36,13 +36,13 @@ describe(':terminal altscreen', function() line7 | line8 | ^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) enter_altscreen() screen:expect([[ |*5 ^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) eq(10, api.nvim_buf_line_count(0)) end) @@ -69,7 +69,7 @@ describe(':terminal altscreen', function() line7 | line8 | ^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed('gg') screen:expect([[ @@ -104,7 +104,7 @@ describe(':terminal altscreen', function() line15 | line16 | ^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -133,7 +133,7 @@ describe(':terminal altscreen', function() |*2 rows: 4, cols: 50 | ^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end @@ -161,7 +161,7 @@ describe(':terminal altscreen', function() line6 | line7 | ^line8 | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) end) diff --git a/test/functional/terminal/api_spec.lua b/test/functional/terminal/api_spec.lua index a8e5367176..691f64ae3e 100644 --- a/test/functional/terminal/api_spec.lua +++ b/test/functional/terminal/api_spec.lua @@ -31,14 +31,12 @@ describe('api', function() end) it('qa! RPC request during insert-mode', function() - screen:expect { - grid = [[ + screen:expect([[ ^ | - {4:~ }|*4 + {100:~ }|*4 | - {3:-- TERMINAL --} | - ]], - } + {5:-- TERMINAL --} | + ]]) -- Start the socket from the child nvim. tt.feed_data(":echo serverstart('" .. socket_name .. "')\n") @@ -46,9 +44,9 @@ describe('api', function() -- Wait for socket creation. screen:expect([[ ^ | - {4:~ }|*4 + {100:~ }|*4 ]] .. socket_name .. [[ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) local socket_session1 = n.connect(socket_name) @@ -58,9 +56,9 @@ describe('api', function() -- Wait for stdin to be processed. screen:expect([[ [tui] insert-mode^ | - {4:~ }|*4 - {3:-- INSERT --} | - {3:-- TERMINAL --} | + {100:~ }|*4 + {5:-- INSERT --} | + {5:-- TERMINAL --} | ]]) ok((socket_session1:request('nvim_ui_attach', 42, 6, { rgb = true }))) @@ -74,9 +72,9 @@ describe('api', function() [socket 1] this is more t | han 25 columns | [socket 2] input^ | - {4:~ } | - {3:-- INSERT --} | - {3:-- TERMINAL --} | + {100:~ } | + {5:-- INSERT --} | + {5:-- TERMINAL --} | ]]) socket_session1:request('nvim_command', 'qa!') diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua index f9266d36ae..9a4fe67849 100644 --- a/test/functional/terminal/buffer_spec.lua +++ b/test/functional/terminal/buffer_spec.lua @@ -69,7 +69,7 @@ describe(':terminal buffer', function() feed(':set bufhidden=wipe:enew') screen:expect([[ ^ | - {4:~ }|*5 + {100:~ }|*5 :enew | ]]) end) @@ -78,7 +78,7 @@ describe(':terminal buffer', function() feed(':bnext:l') screen:expect([[ ^ | - {4:~ }|*5 + {100:~ }|*5 | ]]) end) @@ -111,7 +111,7 @@ describe(':terminal buffer', function() tty ready | ^ | |*4 - {8:E21: Cannot make changes, 'modifiable' is off} | + {101:E21: Cannot make changes, 'modifiable' is off} | ]]) end) @@ -162,13 +162,13 @@ describe(':terminal buffer', function() feed(':bd!') screen:expect([[ ^ | - {4:~ }|*5 + {100:~ }|*5 :bd! | ]]) feed_command('bnext') screen:expect([[ ^ | - {4:~ }|*5 + {100:~ }|*5 :bnext | ]]) end) @@ -195,11 +195,11 @@ describe(':terminal buffer', function() -- We should be in a new buffer now. screen:expect([[ ab^c | - {4:~ }| - {5:========== }| + {100:~ }| + {3:========== }| rows: 2, cols: 50 | | - {18:========== }| + {119:========== }| | ]]) @@ -236,7 +236,7 @@ describe(':terminal buffer', function() ydaer ytt| ^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| |*4 - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) command('bdelete!') end) @@ -274,35 +274,29 @@ describe(':terminal buffer', function() it([[can use temporary normal mode ]], function() eq('t', fn.mode(1)) feed [[]] - screen:expect { - grid = [[ + screen:expect([[ tty ready | ^ | |*4 - {3:-- (terminal) --} | - ]], - } + {5:-- (terminal) --} | + ]]) eq('ntT', fn.mode(1)) feed [[:let g:x = 17]] - screen:expect { - grid = [[ + screen:expect([[ tty ready | | |*4 :let g:x = 17^ | - ]], - } + ]]) feed [[]] - screen:expect { - grid = [[ + screen:expect([[ tty ready | ^ | |*4 - {3:-- TERMINAL --} | - ]], - } + {5:-- TERMINAL --} | + ]]) eq('t', fn.mode(1)) end) @@ -329,9 +323,9 @@ describe(':terminal buffer', function() api.nvim_set_current_buf(term_buf) screen:expect([[ tty ready │ | - ^rows: 5, cols: 25 │{4:~ }| - │{4:~ }|*3 - {17:foo [-] }{1:[No Name] }| + ^rows: 5, cols: 25 │{100:~ }| + │{100:~ }|*3 + {120:foo [-] }{2:[No Name] }| | ]]) @@ -684,10 +678,10 @@ describe('terminal input', function() }) screen:expect([[ ^ | - {4:~ }|*3 - {5:[No Name] 0,0-1 All}| + {100:~ }|*3 + {3:[No Name] 0,0-1 All}| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) local keys = { '', @@ -769,10 +763,10 @@ describe('terminal input', function() feed(key) screen:expect(([[ | - {4:~ }|*3 - {5:[No Name] 0,0-1 All}| + {100:~ }|*3 + {3:[No Name] 0,0-1 All}| %s^ {MATCH: *}| - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]):format(key:gsub('<%d+,%d+>$', ''))) end end) diff --git a/test/functional/terminal/channel_spec.lua b/test/functional/terminal/channel_spec.lua index bb97411f43..03a8e4821a 100644 --- a/test/functional/terminal/channel_spec.lua +++ b/test/functional/terminal/channel_spec.lua @@ -144,80 +144,63 @@ describe('no crash when TermOpen autocommand', function() api.nvim_set_option_value('shell', testprg('shell-test'), {}) command('set shellcmdflag=EXE shellredir= shellpipe= shellquote= shellxquote=') screen = Screen.new(60, 4) - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, - }) end) it('processes job exit event when using jobstart(…,{term=true})', function() command([[autocmd TermOpen * call input('')]]) async_meths.nvim_command('terminal foobar') - screen:expect { - grid = [[ + screen:expect([[ | - {0:~ }|*2 + {1:~ }|*2 ^ | - ]], - } + ]]) feed('') - screen:expect { - grid = [[ + screen:expect([[ ^ready $ foobar | | [Process exited 0] | | - ]], - } + ]]) feed('i') - screen:expect { - grid = [[ + screen:expect([[ ^ | - {0:~ }|*2 + {1:~ }|*2 | - ]], - } + ]]) assert_alive() end) it('wipes buffer and processes events when using jobstart(…,{term=true})', function() command([[autocmd TermOpen * bwipe! | call input('')]]) async_meths.nvim_command('terminal foobar') - screen:expect { - grid = [[ + screen:expect([[ | - {0:~ }|*2 + {1:~ }|*2 ^ | - ]], - } + ]]) feed('') - screen:expect { - grid = [[ + screen:expect([[ ^ | - {0:~ }|*2 + {1:~ }|*2 | - ]], - } + ]]) assert_alive() end) it('wipes buffer and processes events when using nvim_open_term()', function() command([[autocmd TermOpen * bwipe! | call input('')]]) async_meths.nvim_open_term(0, {}) - screen:expect { - grid = [[ + screen:expect([[ | - {0:~ }|*2 + {1:~ }|*2 ^ | - ]], - } + ]]) feed('') - screen:expect { - grid = [[ + screen:expect([[ ^ | - {0:~ }|*2 + {1:~ }|*2 | - ]], - } + ]]) assert_alive() end) end) @@ -236,8 +219,7 @@ describe('nvim_open_term', function() local term = api.nvim_open_term(buf, { force_crlf = true }) api.nvim_win_set_buf(win, buf) api.nvim_chan_send(term, 'here\nthere\nfoo\r\nbar\n\ntest') - screen:expect { - grid = [[ + screen:expect([[ ^here | there | foo | @@ -245,11 +227,9 @@ describe('nvim_open_term', function() | test | |*4 - ]], - } + ]]) api.nvim_chan_send(term, '\nfirst') - screen:expect { - grid = [[ + screen:expect([[ ^here | there | foo | @@ -258,8 +238,7 @@ describe('nvim_open_term', function() test | first | |*3 - ]], - } + ]]) end) it('with force_crlf=false does not convert newlines', function() @@ -268,10 +247,10 @@ describe('nvim_open_term', function() local term = api.nvim_open_term(buf, { force_crlf = false }) api.nvim_win_set_buf(win, buf) api.nvim_chan_send(term, 'here\nthere') - screen:expect { grid = [[ + screen:expect([[ ^here | there | |*8 - ]] } + ]]) end) end) diff --git a/test/functional/terminal/cursor_spec.lua b/test/functional/terminal/cursor_spec.lua index 1e039cd5ef..0be8321d24 100644 --- a/test/functional/terminal/cursor_spec.lua +++ b/test/functional/terminal/cursor_spec.lua @@ -37,7 +37,7 @@ describe(':terminal cursor', function() tty ready | testing cursor^ | |*4 - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -57,36 +57,36 @@ describe(':terminal cursor', function() it('is positioned correctly when unfocused', function() screen:expect([[ - {7: 1 }tty ready | - {7: 2 }^rows: 6, cols: 46 | - {7: 3 } | - {7: 4 } | - {7: 5 } | - {7: 6 } | + {121: 1 }tty ready | + {121: 2 }^rows: 6, cols: 46 | + {121: 3 } | + {121: 4 } | + {121: 5 } | + {121: 6 } | :set number | ]]) end) it('is positioned correctly when focused', function() screen:expect([[ - {7: 1 }tty ready | - {7: 2 }^rows: 6, cols: 46 | - {7: 3 } | - {7: 4 } | - {7: 5 } | - {7: 6 } | + {121: 1 }tty ready | + {121: 2 }^rows: 6, cols: 46 | + {121: 3 } | + {121: 4 } | + {121: 5 } | + {121: 6 } | :set number | ]]) feed('i') n.poke_eventloop() screen:expect([[ - {7: 1 }tty ready | - {7: 2 }rows: 6, cols: 46 | - {7: 3 }^ | - {7: 4 } | - {7: 5 } | - {7: 6 } | - {3:-- TERMINAL --} | + {121: 1 }tty ready | + {121: 2 }rows: 6, cols: 46 | + {121: 3 }^ | + {121: 4 } | + {121: 5 } | + {121: 6 } | + {5:-- TERMINAL --} | ]]) end) end) @@ -98,35 +98,25 @@ describe(':terminal cursor', function() screen:expect([[ tty ready | |*5 - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) show_cursor() screen:expect([[ tty ready | ^ | |*4 - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- same for when the terminal is unfocused feed('') hide_cursor() - screen:expect({ - grid = [[ + screen:expect([[ tty ready | ^ | |*5 - ]], - unchanged = true, - }) + ]]) show_cursor() - screen:expect({ - grid = [[ - tty ready | - ^ | - |*5 - ]], - unchanged = true, - }) + screen:expect_unchanged() end) it('becomes visible when exiting Terminal mode', function() @@ -135,7 +125,7 @@ describe(':terminal cursor', function() screen:expect([[ tty ready | |*5 - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed('') screen:expect([[ @@ -147,7 +137,7 @@ describe(':terminal cursor', function() screen:expect([[ tty ready | |*5 - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- Cursor is hidden; now request to show it while in a TermLeave autocmd. @@ -169,22 +159,22 @@ describe(':terminal cursor', function() command([[call chansend(chan, "\e[?25l") | new floob | call chansend(chan, "\e[?25h")]]) screen:expect([[ ^ | - {4:~ }| - {5:floob }| + {100:~ }| + {3:floob }| |*2 - {18:[Scratch] [-] }| + {119:[Scratch] [-] }| | ]]) feed('pi') screen:expect([[ | - {4:~ }| - {1:floob }| + {100:~ }| + {2:floob }| ^ | | - {17:[Scratch] [-] }| - {3:-- TERMINAL --} | + {120:[Scratch] [-] }| + {5:-- TERMINAL --} | ]]) end) @@ -207,7 +197,7 @@ describe(':terminal cursor', function() screen:expect([[ tty ready | |*5 - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed([[]]) @@ -235,11 +225,11 @@ describe(':terminal cursor', function() tt.feed_csi(('%d q'):format(k)) screen:expect({ grid = [[ - tty ready | - ^ | - |*4 - {3:-- TERMINAL --} | - ]], + tty ready | + ^ | + |*4 + {5:-- TERMINAL --} | + ]], condition = function() if v.blink then eq(500, screen._mode_info[terminal_mode_idx].blinkon) @@ -282,11 +272,11 @@ describe(':terminal cursor', function() tt.feed_csi('5 q') screen:expect({ grid = [[ - tty ready | - ^ | - |*4 - {3:-- TERMINAL --} | - ]], + tty ready | + ^ | + |*4 + {5:-- TERMINAL --} | + ]], condition = function() eq(500, screen._mode_info[terminal_mode_idx].blinkon) eq(500, screen._mode_info[terminal_mode_idx].blinkoff) @@ -297,11 +287,11 @@ describe(':terminal cursor', function() tt.hide_cursor() screen:expect({ grid = [[ - tty ready | - | - |*4 - {3:-- TERMINAL --} | - ]], + tty ready | + | + |*4 + {5:-- TERMINAL --} | + ]], condition = function() eq(500, screen._mode_info[terminal_mode_idx].blinkon) eq(500, screen._mode_info[terminal_mode_idx].blinkoff) @@ -318,14 +308,14 @@ describe(':terminal cursor', function() feed('i') screen:expect({ grid = [[ - tty ready | - ^ | - {17:~~~ }| - rows: 2, cols: 50 | - | - {18:~~~ }| - {3:-- TERMINAL --} | - ]], + tty ready | + ^ | + {120:~~~ }| + rows: 2, cols: 50 | + | + {119:~~~ }| + {5:-- TERMINAL --} | + ]], condition = function() -- New terminal, cursor resets to defaults eq(500, screen._mode_info[terminal_mode_idx].blinkon) @@ -338,14 +328,14 @@ describe(':terminal cursor', function() tt.feed_csi('4 q') screen:expect({ grid = [[ - tty ready | - ^ | - {17:~~~ }| - rows: 2, cols: 50 | - | - {18:~~~ }| - {3:-- TERMINAL --} | - ]], + tty ready | + ^ | + {120:~~~ }| + rows: 2, cols: 50 | + | + {119:~~~ }| + {5:-- TERMINAL --} | + ]], condition = function() eq(0, screen._mode_info[terminal_mode_idx].blinkon) eq(0, screen._mode_info[terminal_mode_idx].blinkoff) @@ -357,14 +347,14 @@ describe(':terminal cursor', function() command('wincmd p') screen:expect({ grid = [[ - tty ready | - | - {18:~~~ }| - rows: 2, cols: 50 | - | - {17:~~~ }| - {3:-- TERMINAL --} | - ]], + tty ready | + | + {119:~~~ }| + rows: 2, cols: 50 | + | + {120:~~~ }| + {5:-- TERMINAL --} | + ]], condition = function() eq(500, screen._mode_info[terminal_mode_idx].blinkon) eq(500, screen._mode_info[terminal_mode_idx].blinkoff) @@ -387,7 +377,7 @@ describe(':terminal cursor', function() ^ | ~ |*4 | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed('i') @@ -395,7 +385,7 @@ describe(':terminal cursor', function() ^ | ~ |*4 | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -437,8 +427,8 @@ describe(':terminal cursor', function() screen:expect([[ ^ │ | │ |*4 - {17:[Scratch] [-] }{18:[Scratch] [-] }| - {3:-- TERMINAL --} | + {120:[Scratch] [-] }{119:[Scratch] [-] }| + {5:-- TERMINAL --} | ]]) eq('block', screen._mode_info[terminal_mode_idx].cursor_shape) eq(500, screen._mode_info[terminal_mode_idx].blinkon) @@ -463,8 +453,8 @@ describe(':terminal cursor', function() screen:expect([[ │^ | │ |*4 - {18:[Scratch] [-] }{17:[Scratch] [-] }| - {3:-- TERMINAL --} | + {119:[Scratch] [-] }{120:[Scratch] [-] }| + {5:-- TERMINAL --} | ]]) eq('horizontal', screen._mode_info[terminal_mode_idx].cursor_shape) eq(0, screen._mode_info[terminal_mode_idx].blinkon) @@ -498,7 +488,7 @@ describe('buffer cursor position is correct in terminal without number column', |*4 Entering Ex mode. Type "visual" to go to Normal mode. | :^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end @@ -515,7 +505,7 @@ describe('buffer cursor position is correct in terminal without number column', |*4 Entering Ex mode. Type "visual" to go to Normal mode. | :aaaaaaaa^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) eq({ 6, 9 }, eval('nvim_win_get_cursor(0)')) feed([[]]) @@ -534,7 +524,7 @@ describe('buffer cursor position is correct in terminal without number column', |*4 Entering Ex mode. Type "visual" to go to Normal mode. | :aaaaaa^aa | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) eq({ 6, 7 }, eval('nvim_win_get_cursor(0)')) feed([[]]) @@ -553,7 +543,7 @@ describe('buffer cursor position is correct in terminal without number column', |*4 Entering Ex mode. Type "visual" to go to Normal mode. | :a^aaaaaaa | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) eq({ 6, 2 }, eval('nvim_win_get_cursor(0)')) feed([[]]) @@ -578,7 +568,7 @@ describe('buffer cursor position is correct in terminal without number column', |*4 Entering Ex mode. Type "visual" to go to Normal mode. | :µµµµµµµµ^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) eq({ 6, 17 }, eval('nvim_win_get_cursor(0)')) feed([[]]) @@ -597,7 +587,7 @@ describe('buffer cursor position is correct in terminal without number column', |*4 Entering Ex mode. Type "visual" to go to Normal mode. | :µµµµµµ^µµ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) eq({ 6, 13 }, eval('nvim_win_get_cursor(0)')) feed([[]]) @@ -616,7 +606,7 @@ describe('buffer cursor position is correct in terminal without number column', |*4 Entering Ex mode. Type "visual" to go to Normal mode. | :µ^µµµµµµµ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) eq({ 6, 3 }, eval('nvim_win_get_cursor(0)')) feed([[]]) @@ -641,7 +631,7 @@ describe('buffer cursor position is correct in terminal without number column', |*4 Entering Ex mode. Type "visual" to go to Normal mode. | :µ̳µ̳µ̳µ̳µ̳µ̳µ̳µ̳^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) eq({ 6, 33 }, eval('nvim_win_get_cursor(0)')) feed([[]]) @@ -661,7 +651,7 @@ describe('buffer cursor position is correct in terminal without number column', |*4 Entering Ex mode. Type "visual" to go to Normal mode. | :µ̳µ̳µ̳µ̳µ̳µ̳^µ̳µ̳ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) eq({ 6, 25 }, eval('nvim_win_get_cursor(0)')) feed([[]]) @@ -681,7 +671,7 @@ describe('buffer cursor position is correct in terminal without number column', |*4 Entering Ex mode. Type "visual" to go to Normal mode. | :µ̳^µ̳µ̳µ̳µ̳µ̳µ̳µ̳ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) eq({ 6, 5 }, eval('nvim_win_get_cursor(0)')) feed([[]]) @@ -706,7 +696,7 @@ describe('buffer cursor position is correct in terminal without number column', |*4 Entering Ex mode. Type "visual" to go to Normal mode. | :哦哦哦哦哦哦哦哦^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) eq({ 6, 25 }, eval('nvim_win_get_cursor(0)')) feed([[]]) @@ -725,7 +715,7 @@ describe('buffer cursor position is correct in terminal without number column', |*4 Entering Ex mode. Type "visual" to go to Normal mode. | :哦哦哦哦哦哦^哦哦 | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) eq({ 6, 19 }, eval('nvim_win_get_cursor(0)')) feed([[]]) @@ -744,7 +734,7 @@ describe('buffer cursor position is correct in terminal without number column', |*4 Entering Ex mode. Type "visual" to go to Normal mode. | :哦^哦哦哦哦哦哦哦 | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) eq({ 6, 4 }, eval('nvim_win_get_cursor(0)')) feed([[]]) @@ -765,7 +755,7 @@ describe('buffer cursor position is correct in terminal without number column', |*4 Entering Ex mode. Type "visual" to go to Normal mode. | :aaaaaaaa ^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) matches('^:aaaaaaaa [ ]*$', eval('nvim_get_current_line()')) eq({ 6, 13 }, eval('nvim_win_get_cursor(0)')) @@ -807,13 +797,13 @@ describe('buffer cursor position is correct in terminal with number column', fun cols = 70, }) screen:expect([[ - {7: 1 } | - {7: 2 } | - {7: 3 } | - {7: 4 } | - {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | - {7: 6 }:^ | - {3:-- TERMINAL --} | + {121: 1 } | + {121: 2 } | + {121: 3 } | + {121: 4 } | + {121: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | + {121: 6 }:^ | + {5:-- TERMINAL --} | ]]) end @@ -830,23 +820,23 @@ describe('buffer cursor position is correct in terminal with number column', fun it('at the end', function() feed('r') screen:expect([[ - {7: 1 } | - {7: 2 } | - {7: 3 } | - {7: 4 } | - {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | - {7: 6 }:aaaaaaaa^ | - {3:-- TERMINAL --} | + {121: 1 } | + {121: 2 } | + {121: 3 } | + {121: 4 } | + {121: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | + {121: 6 }:aaaaaaaa^ | + {5:-- TERMINAL --} | ]]) eq({ 6, 9 }, eval('nvim_win_get_cursor(0)')) feed([[]]) screen:expect([[ - {7: 1 } | - {7: 2 } | - {7: 3 } | - {7: 4 } | - {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | - {7: 6 }:aaaaaaa^a | + {121: 1 } | + {121: 2 } | + {121: 3 } | + {121: 4 } | + {121: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | + {121: 6 }:aaaaaaa^a | | ]]) eq({ 6, 8 }, eval('nvim_win_get_cursor(0)')) @@ -855,23 +845,23 @@ describe('buffer cursor position is correct in terminal with number column', fun it('near the end', function() feed('r') screen:expect([[ - {7: 1 } | - {7: 2 } | - {7: 3 } | - {7: 4 } | - {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | - {7: 6 }:aaaaaa^aa | - {3:-- TERMINAL --} | + {121: 1 } | + {121: 2 } | + {121: 3 } | + {121: 4 } | + {121: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | + {121: 6 }:aaaaaa^aa | + {5:-- TERMINAL --} | ]]) eq({ 6, 7 }, eval('nvim_win_get_cursor(0)')) feed([[]]) screen:expect([[ - {7: 1 } | - {7: 2 } | - {7: 3 } | - {7: 4 } | - {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | - {7: 6 }:aaaaa^aaa | + {121: 1 } | + {121: 2 } | + {121: 3 } | + {121: 4 } | + {121: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | + {121: 6 }:aaaaa^aaa | | ]]) eq({ 6, 6 }, eval('nvim_win_get_cursor(0)')) @@ -880,23 +870,23 @@ describe('buffer cursor position is correct in terminal with number column', fun it('near the start', function() feed('r') screen:expect([[ - {7: 1 } | - {7: 2 } | - {7: 3 } | - {7: 4 } | - {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | - {7: 6 }:a^aaaaaaa | - {3:-- TERMINAL --} | + {121: 1 } | + {121: 2 } | + {121: 3 } | + {121: 4 } | + {121: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | + {121: 6 }:a^aaaaaaa | + {5:-- TERMINAL --} | ]]) eq({ 6, 2 }, eval('nvim_win_get_cursor(0)')) feed([[]]) screen:expect([[ - {7: 1 } | - {7: 2 } | - {7: 3 } | - {7: 4 } | - {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | - {7: 6 }:^aaaaaaaa | + {121: 1 } | + {121: 2 } | + {121: 3 } | + {121: 4 } | + {121: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | + {121: 6 }:^aaaaaaaa | | ]]) eq({ 6, 1 }, eval('nvim_win_get_cursor(0)')) @@ -911,23 +901,23 @@ describe('buffer cursor position is correct in terminal with number column', fun it('at the end', function() feed('r') screen:expect([[ - {7: 1 } | - {7: 2 } | - {7: 3 } | - {7: 4 } | - {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | - {7: 6 }:µµµµµµµµ^ | - {3:-- TERMINAL --} | + {121: 1 } | + {121: 2 } | + {121: 3 } | + {121: 4 } | + {121: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | + {121: 6 }:µµµµµµµµ^ | + {5:-- TERMINAL --} | ]]) eq({ 6, 17 }, eval('nvim_win_get_cursor(0)')) feed([[]]) screen:expect([[ - {7: 1 } | - {7: 2 } | - {7: 3 } | - {7: 4 } | - {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | - {7: 6 }:µµµµµµµ^µ | + {121: 1 } | + {121: 2 } | + {121: 3 } | + {121: 4 } | + {121: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | + {121: 6 }:µµµµµµµ^µ | | ]]) eq({ 6, 15 }, eval('nvim_win_get_cursor(0)')) @@ -936,23 +926,23 @@ describe('buffer cursor position is correct in terminal with number column', fun it('near the end', function() feed('r') screen:expect([[ - {7: 1 } | - {7: 2 } | - {7: 3 } | - {7: 4 } | - {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | - {7: 6 }:µµµµµµ^µµ | - {3:-- TERMINAL --} | + {121: 1 } | + {121: 2 } | + {121: 3 } | + {121: 4 } | + {121: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | + {121: 6 }:µµµµµµ^µµ | + {5:-- TERMINAL --} | ]]) eq({ 6, 13 }, eval('nvim_win_get_cursor(0)')) feed([[]]) screen:expect([[ - {7: 1 } | - {7: 2 } | - {7: 3 } | - {7: 4 } | - {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | - {7: 6 }:µµµµµ^µµµ | + {121: 1 } | + {121: 2 } | + {121: 3 } | + {121: 4 } | + {121: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | + {121: 6 }:µµµµµ^µµµ | | ]]) eq({ 6, 11 }, eval('nvim_win_get_cursor(0)')) @@ -961,23 +951,23 @@ describe('buffer cursor position is correct in terminal with number column', fun it('near the start', function() feed('r') screen:expect([[ - {7: 1 } | - {7: 2 } | - {7: 3 } | - {7: 4 } | - {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | - {7: 6 }:µ^µµµµµµµ | - {3:-- TERMINAL --} | + {121: 1 } | + {121: 2 } | + {121: 3 } | + {121: 4 } | + {121: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | + {121: 6 }:µ^µµµµµµµ | + {5:-- TERMINAL --} | ]]) eq({ 6, 3 }, eval('nvim_win_get_cursor(0)')) feed([[]]) screen:expect([[ - {7: 1 } | - {7: 2 } | - {7: 3 } | - {7: 4 } | - {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | - {7: 6 }:^µµµµµµµµ | + {121: 1 } | + {121: 2 } | + {121: 3 } | + {121: 4 } | + {121: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | + {121: 6 }:^µµµµµµµµ | | ]]) eq({ 6, 1 }, eval('nvim_win_get_cursor(0)')) @@ -992,23 +982,23 @@ describe('buffer cursor position is correct in terminal with number column', fun it('at the end', function() feed('r') screen:expect([[ - {7: 1 } | - {7: 2 } | - {7: 3 } | - {7: 4 } | - {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | - {7: 6 }:µ̳µ̳µ̳µ̳µ̳µ̳µ̳µ̳^ | - {3:-- TERMINAL --} | + {121: 1 } | + {121: 2 } | + {121: 3 } | + {121: 4 } | + {121: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | + {121: 6 }:µ̳µ̳µ̳µ̳µ̳µ̳µ̳µ̳^ | + {5:-- TERMINAL --} | ]]) eq({ 6, 33 }, eval('nvim_win_get_cursor(0)')) feed([[]]) screen:expect([[ - {7: 1 } | - {7: 2 } | - {7: 3 } | - {7: 4 } | - {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | - {7: 6 }:µ̳µ̳µ̳µ̳µ̳µ̳µ̳^µ̳ | + {121: 1 } | + {121: 2 } | + {121: 3 } | + {121: 4 } | + {121: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | + {121: 6 }:µ̳µ̳µ̳µ̳µ̳µ̳µ̳^µ̳ | | ]]) eq({ 6, 29 }, eval('nvim_win_get_cursor(0)')) @@ -1018,23 +1008,23 @@ describe('buffer cursor position is correct in terminal with number column', fun skip(is_os('win')) feed('r') screen:expect([[ - {7: 1 } | - {7: 2 } | - {7: 3 } | - {7: 4 } | - {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | - {7: 6 }:µ̳µ̳µ̳µ̳µ̳µ̳^µ̳µ̳ | - {3:-- TERMINAL --} | + {121: 1 } | + {121: 2 } | + {121: 3 } | + {121: 4 } | + {121: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | + {121: 6 }:µ̳µ̳µ̳µ̳µ̳µ̳^µ̳µ̳ | + {5:-- TERMINAL --} | ]]) eq({ 6, 25 }, eval('nvim_win_get_cursor(0)')) feed([[]]) screen:expect([[ - {7: 1 } | - {7: 2 } | - {7: 3 } | - {7: 4 } | - {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | - {7: 6 }:µ̳µ̳µ̳µ̳µ̳^µ̳µ̳µ̳ | + {121: 1 } | + {121: 2 } | + {121: 3 } | + {121: 4 } | + {121: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | + {121: 6 }:µ̳µ̳µ̳µ̳µ̳^µ̳µ̳µ̳ | | ]]) eq({ 6, 21 }, eval('nvim_win_get_cursor(0)')) @@ -1044,23 +1034,23 @@ describe('buffer cursor position is correct in terminal with number column', fun skip(is_os('win')) feed('r') screen:expect([[ - {7: 1 } | - {7: 2 } | - {7: 3 } | - {7: 4 } | - {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | - {7: 6 }:µ̳^µ̳µ̳µ̳µ̳µ̳µ̳µ̳ | - {3:-- TERMINAL --} | + {121: 1 } | + {121: 2 } | + {121: 3 } | + {121: 4 } | + {121: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | + {121: 6 }:µ̳^µ̳µ̳µ̳µ̳µ̳µ̳µ̳ | + {5:-- TERMINAL --} | ]]) eq({ 6, 5 }, eval('nvim_win_get_cursor(0)')) feed([[]]) screen:expect([[ - {7: 1 } | - {7: 2 } | - {7: 3 } | - {7: 4 } | - {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | - {7: 6 }:^µ̳µ̳µ̳µ̳µ̳µ̳µ̳µ̳ | + {121: 1 } | + {121: 2 } | + {121: 3 } | + {121: 4 } | + {121: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | + {121: 6 }:^µ̳µ̳µ̳µ̳µ̳µ̳µ̳µ̳ | | ]]) eq({ 6, 1 }, eval('nvim_win_get_cursor(0)')) @@ -1075,23 +1065,23 @@ describe('buffer cursor position is correct in terminal with number column', fun it('at the end', function() feed('r') screen:expect([[ - {7: 1 } | - {7: 2 } | - {7: 3 } | - {7: 4 } | - {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | - {7: 6 }:哦哦哦哦哦哦哦哦^ | - {3:-- TERMINAL --} | + {121: 1 } | + {121: 2 } | + {121: 3 } | + {121: 4 } | + {121: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | + {121: 6 }:哦哦哦哦哦哦哦哦^ | + {5:-- TERMINAL --} | ]]) eq({ 6, 25 }, eval('nvim_win_get_cursor(0)')) feed([[]]) screen:expect([[ - {7: 1 } | - {7: 2 } | - {7: 3 } | - {7: 4 } | - {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | - {7: 6 }:哦哦哦哦哦哦哦^哦 | + {121: 1 } | + {121: 2 } | + {121: 3 } | + {121: 4 } | + {121: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | + {121: 6 }:哦哦哦哦哦哦哦^哦 | | ]]) eq({ 6, 22 }, eval('nvim_win_get_cursor(0)')) @@ -1100,23 +1090,23 @@ describe('buffer cursor position is correct in terminal with number column', fun it('near the end', function() feed('r') screen:expect([[ - {7: 1 } | - {7: 2 } | - {7: 3 } | - {7: 4 } | - {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | - {7: 6 }:哦哦哦哦哦哦^哦哦 | - {3:-- TERMINAL --} | + {121: 1 } | + {121: 2 } | + {121: 3 } | + {121: 4 } | + {121: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | + {121: 6 }:哦哦哦哦哦哦^哦哦 | + {5:-- TERMINAL --} | ]]) eq({ 6, 19 }, eval('nvim_win_get_cursor(0)')) feed([[]]) screen:expect([[ - {7: 1 } | - {7: 2 } | - {7: 3 } | - {7: 4 } | - {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | - {7: 6 }:哦哦哦哦哦^哦哦哦 | + {121: 1 } | + {121: 2 } | + {121: 3 } | + {121: 4 } | + {121: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | + {121: 6 }:哦哦哦哦哦^哦哦哦 | | ]]) eq({ 6, 16 }, eval('nvim_win_get_cursor(0)')) @@ -1125,23 +1115,23 @@ describe('buffer cursor position is correct in terminal with number column', fun it('near the start', function() feed('r') screen:expect([[ - {7: 1 } | - {7: 2 } | - {7: 3 } | - {7: 4 } | - {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | - {7: 6 }:哦^哦哦哦哦哦哦哦 | - {3:-- TERMINAL --} | + {121: 1 } | + {121: 2 } | + {121: 3 } | + {121: 4 } | + {121: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | + {121: 6 }:哦^哦哦哦哦哦哦哦 | + {5:-- TERMINAL --} | ]]) eq({ 6, 4 }, eval('nvim_win_get_cursor(0)')) feed([[]]) screen:expect([[ - {7: 1 } | - {7: 2 } | - {7: 3 } | - {7: 4 } | - {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | - {7: 6 }:^哦哦哦哦哦哦哦哦 | + {121: 1 } | + {121: 2 } | + {121: 3 } | + {121: 4 } | + {121: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | + {121: 6 }:^哦哦哦哦哦哦哦哦 | | ]]) eq({ 6, 1 }, eval('nvim_win_get_cursor(0)')) @@ -1152,24 +1142,24 @@ describe('buffer cursor position is correct in terminal with number column', fun setup_ex_register('aaaaaaaa ') feed('r') screen:expect([[ - {7: 1 } | - {7: 2 } | - {7: 3 } | - {7: 4 } | - {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | - {7: 6 }:aaaaaaaa ^ | - {3:-- TERMINAL --} | + {121: 1 } | + {121: 2 } | + {121: 3 } | + {121: 4 } | + {121: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | + {121: 6 }:aaaaaaaa ^ | + {5:-- TERMINAL --} | ]]) matches('^:aaaaaaaa [ ]*$', eval('nvim_get_current_line()')) eq({ 6, 13 }, eval('nvim_win_get_cursor(0)')) feed([[]]) screen:expect([[ - {7: 1 } | - {7: 2 } | - {7: 3 } | - {7: 4 } | - {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | - {7: 6 }:aaaaaaaa ^ | + {121: 1 } | + {121: 2 } | + {121: 3 } | + {121: 4 } | + {121: 5 }Entering Ex mode. Type "visual" to go to Normal mode. | + {121: 6 }:aaaaaaaa ^ | | ]]) eq({ 6, 12 }, eval('nvim_win_get_cursor(0)')) diff --git a/test/functional/terminal/highlight_spec.lua b/test/functional/terminal/highlight_spec.lua index 2560e57341..1fc0f8deb5 100644 --- a/test/functional/terminal/highlight_spec.lua +++ b/test/functional/terminal/highlight_spec.lua @@ -194,13 +194,7 @@ end) it('CursorLine and CursorColumn work in :terminal buffer in Normal mode', function() clear() local screen = Screen.new(50, 7) - screen:set_default_attr_ids({ - [1] = { background = Screen.colors.Grey90 }, -- CursorLine, CursorColumn - [2] = { reverse = true }, - [3] = { bold = true }, -- ModeMsg - [4] = { background = Screen.colors.Grey90, reverse = true }, - [5] = { background = Screen.colors.Red }, - }) + screen:add_extra_attr_ids({ [100] = { background = Screen.colors.Gray90, reverse = true } }) command(("enew | call jobstart(['%s'], {'term':v:true})"):format(testprg('tty-test'))) screen:expect([[ ^tty ready | @@ -219,12 +213,12 @@ it('CursorLine and CursorColumn work in :terminal buffer in Normal mode', functi command('set cursorline cursorcolumn') feed('j10w') screen:expect([[ - tty ready {1: } | - foobar foobar{1: }foobar foobar foobar foobar foobar | - {1:foobar foobar ^foobar 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 {1: } | + tty ready {21: } | + foobar foobar{21: }foobar foobar foobar foobar foobar | + {21:foobar foobar ^foobar foobar foobar foobar foobar f}| + oobar foobar f{21:o}obar foobar foobar foobar foobar fo| + obar foobar fo{21:o}bar foobar foobar foobar foobar foo| + bar foobar {21: } | | ]]) -- Entering terminal mode disables 'cursorline' and 'cursorcolumn'. @@ -236,17 +230,17 @@ it('CursorLine and CursorColumn work in :terminal buffer in Normal mode', functi oobar foobar foobar foobar foobar foobar foobar fo| obar foobar foobar foobar foobar foobar foobar foo| bar foobar^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- Leaving terminal mode restores old values. feed([[]]) 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 }| + tty ready{21: } | + foobar f{21:o}obar foobar foobar foobar foobar foobar | + foobar fo{21:o}bar foobar foobar foobar foobar foobar f| + oobar foo{21:b}ar foobar foobar foobar foobar foobar fo| + obar foob{21:a}r foobar foobar foobar foobar foobar foo| + {21:bar fooba^r }| | ]]) @@ -260,22 +254,22 @@ it('CursorLine and CursorColumn work in :terminal buffer in Normal mode', functi 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: foobar}{1: }| + tty ready{21: } | + foobar f{21:o}obar foobar foobar foobar foobar foobar | + foobar fo{21:o}bar foobar foobar foobar foobar foobar f| + oobar foo{21:b}ar foobar foobar foobar foobar foobar fo| + obar foob{21:a}r foobar foobar foobar foobar foobar foo| + {21:bar fooba^r}{100: foobar}{21: }| | ]]) feed('2gg15|') screen:expect([[ - 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} | + tty ready {21: } | + {21: foobar foobar^ foobar foobar foobar foobar foobar }| + foobar foobar {21:f}oobar foobar foobar foobar foobar f| + oobar foobar f{21:o}obar foobar foobar foobar foobar fo| + obar foobar fo{21:o}bar foobar foobar foobar foobar foo| + bar foobar{2: foo}{100:b}{2:ar} | | ]]) @@ -287,22 +281,22 @@ it('CursorLine and CursorColumn work in :terminal buffer in Normal mode', functi -- Terminal color has higher precedence screen:expect([[ - 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} | + tty ready {21: } | + {21: foobar foobar foob^ar foobar foobar foobar foobar }| + foobar foobar fooba{21:r} foobar foobar foobar foobar f| + oobar foobar foobar{21: }foobar foobar foobar foobar fo| + obar foobar foobar {21:f}oobar foobar foobar foobar foo| + bar foobar{2: foobar}{30: foobar} | | ]]) feed('G$') screen:expect([[ - 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: }| + tty ready {21: } | + foobar foobar foobar f{21:o}obar foobar foobar foobar | + foobar foobar foobar fo{21:o}bar foobar foobar foobar f| + oobar foobar foobar foo{21:b}ar foobar foobar foobar fo| + obar foobar foobar foob{21:a}r foobar foobar foobar foo| + {21:bar foobar}{100: foobar}{30: fooba^r}{21: }| | ]]) end) @@ -337,14 +331,12 @@ describe(':terminal highlight forwarding', function() tt.feed_data('color') tt.clear_attrs() tt.feed_data('text') - screen:expect { - grid = [[ + screen:expect([[ tty ready | {2:text}{3:color}text^ | |*4 {1:-- TERMINAL --} | - ]], - } + ]]) end) end) @@ -354,16 +346,6 @@ describe(':terminal highlight with custom palette', function() before_each(function() clear() screen = Screen.new(50, 7, { rgb = true }) - screen:set_default_attr_ids({ - [1] = { foreground = tonumber('0x123456') }, -- no fg_indexed when overridden - [2] = { foreground = 12 }, - [3] = { bold = true, reverse = true }, - [5] = { background = 11 }, - [6] = { foreground = 130 }, - [7] = { reverse = true }, - [8] = { background = 11 }, - [9] = { bold = true }, - }) api.nvim_set_var('terminal_color_3', '#123456') command(("enew | call jobstart(['%s'], {'term':v:true})"):format(testprg('tty-test'))) feed('i') @@ -371,7 +353,7 @@ describe(':terminal highlight with custom palette', function() tty ready | ^ | |*4 - {9:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -381,11 +363,12 @@ describe(':terminal highlight with custom palette', function() tt.feed_data('text') tt.clear_attrs() tt.feed_data('text') + screen:add_extra_attr_ids({ [100] = { foreground = tonumber('0x123456') } }) screen:expect([[ tty ready | - {1:text}text^ | + {100:text}text^ | |*4 - {9:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) end) @@ -395,9 +378,7 @@ describe(':terminal', function() it('can display URLs', function() local screen = Screen.new(50, 7) - screen:add_extra_attr_ids { - [100] = { url = 'https://example.com' }, - } + screen:add_extra_attr_ids({ [100] = { url = 'https://example.com' } }) local chan = api.nvim_open_term(0, {}) api.nvim_chan_send( chan, diff --git a/test/functional/terminal/mouse_spec.lua b/test/functional/terminal/mouse_spec.lua index 5898484449..86c58d5ab5 100644 --- a/test/functional/terminal/mouse_spec.lua +++ b/test/functional/terminal/mouse_spec.lua @@ -33,7 +33,7 @@ describe(':terminal mouse', function() line29 | line30 | ^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -108,7 +108,7 @@ describe(':terminal mouse', function() line30 | mouse enabled | ^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -122,7 +122,7 @@ describe(':terminal mouse', function() line30 | mouse enabled | "#^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed('<2,2>') screen:expect([[ @@ -132,7 +132,7 @@ describe(':terminal mouse', function() line30 | mouse enabled | @##^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed('<3,2>') screen:expect([[ @@ -142,7 +142,7 @@ describe(':terminal mouse', function() line30 | mouse enabled | @$#^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed('<3,2>') screen:expect([[ @@ -152,7 +152,7 @@ describe(':terminal mouse', function() line30 | mouse enabled | #$#^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -166,7 +166,7 @@ describe(':terminal mouse', function() line30 | mouse enabled | `!!^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -180,7 +180,7 @@ describe(':terminal mouse', function() line30 | mouse enabled | "#^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed('<1,2>') screen:expect([[ @@ -190,7 +190,7 @@ describe(':terminal mouse', function() line30 | mouse enabled | `"#^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed('<2,2>') screen:expect([[ @@ -200,7 +200,7 @@ describe(':terminal mouse', function() line30 | mouse enabled | @##^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed('<2,2>') screen:expect([[ @@ -210,7 +210,7 @@ describe(':terminal mouse', function() line30 | mouse enabled | `##^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed('<2,2>') screen:expect([[ @@ -220,7 +220,7 @@ describe(':terminal mouse', function() line30 | mouse enabled | ###^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -232,25 +232,25 @@ describe(':terminal mouse', function() feed('<3,0>') eq('nt', eval('mode(1)')) screen:expect([[ - {7: 11 }^line28 | - {7: 12 }line29 | - {7: 13 }line30 | - {7: 14 }mouse enabled | - {7: 15 }rows: 6, cols: 46 | - {7: 16 } | + {121: 11 }^line28 | + {121: 12 }line29 | + {121: 13 }line30 | + {121: 14 }mouse enabled | + {121: 15 }rows: 6, cols: 46 | + {121: 16 } | | ]]) -- If click on the coordinate (0,1) of the region of the terminal -- (i.e. the coordinate (4,1) of vim), 'CSI !"' is sent to the terminal. feed('i<4,1>') screen:expect([[ - {7: 11 }line28 | - {7: 12 }line29 | - {7: 13 }line30 | - {7: 14 }mouse enabled | - {7: 15 }rows: 6, cols: 46 | - {7: 16 } !"^ | - {3:-- TERMINAL --} | + {121: 11 }line28 | + {121: 12 }line29 | + {121: 13 }line30 | + {121: 14 }mouse enabled | + {121: 15 }rows: 6, cols: 46 | + {121: 16 } !"^ | + {5:-- TERMINAL --} | ]]) end) @@ -263,7 +263,7 @@ describe(':terminal mouse', function() rows: 5, cols: 50 | ^ | ========== | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed('<0,5>') screen:expect([[ @@ -290,30 +290,30 @@ describe(':terminal mouse', function() command('rightbelow vnew | wincmd p | startinsert') screen:expect([[ line29 │ | - line30 │{4:~ }| - mouse enabled │{4:~ }| - rows: 5, cols: 24 │{4:~ }| - ^ │{4:~ }| + line30 │{100:~ }| + mouse enabled │{100:~ }| + rows: 5, cols: 24 │{100:~ }| + ^ │{100:~ }| ========== ========== | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed('<24,0>') screen:expect([[ line29 │ | - line30 │{4:~ }| - mouse enabled │{4:~ }| - rows: 5, cols: 24 │{4:~ }| - ^ │{4:~ }| + line30 │{100:~ }| + mouse enabled │{100:~ }| + rows: 5, cols: 24 │{100:~ }| + ^ │{100:~ }| ========== ========== | | ]]) feed('<23,0>') screen:expect([[ line30 │ | - mouse enabled │{4:~ }| - rows: 5, cols: 24 │{4:~ }| - rows: 5, cols: 23 │{4:~ }| - ^ │{4:~ }| + mouse enabled │{100:~ }| + rows: 5, cols: 24 │{100:~ }| + rows: 5, cols: 23 │{100:~ }| + ^ │{100:~ }| ========== ========== | | ]]) @@ -322,17 +322,17 @@ describe(':terminal mouse', function() it('will lose focus if winbar/tabline is clicked', function() command('setlocal winbar=WINBAR') screen:expect([[ - {3:WINBAR }| + {5:WINBAR }| line29 | line30 | mouse enabled | rows: 5, cols: 50 | ^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed('<0,0>') screen:expect([[ - {3:WINBAR }| + {5:WINBAR }| line29 | line30 | mouse enabled | @@ -342,18 +342,18 @@ describe(':terminal mouse', function() ]]) command('set showtabline=2 tabline=TABLINE | startinsert') screen:expect([[ - {1:TABLINE }| - {3:WINBAR }| + {2:TABLINE }| + {5:WINBAR }| mouse enabled | rows: 5, cols: 50 | rows: 4, cols: 50 | ^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed('<0,0>') screen:expect([[ - {1:TABLINE }| - {3:WINBAR }| + {2:TABLINE }| + {5:WINBAR }| mouse enabled | rows: 5, cols: 50 | rows: 4, cols: 50 | @@ -362,17 +362,17 @@ describe(':terminal mouse', function() ]]) command('setlocal winbar= | startinsert') screen:expect([[ - {1:TABLINE }| + {2:TABLINE }| mouse enabled | rows: 5, cols: 50 | rows: 4, cols: 50 | rows: 5, cols: 50 | ^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed('<0,0>') screen:expect([[ - {1:TABLINE }| + {2:TABLINE }| mouse enabled | rows: 5, cols: 50 | rows: 4, cols: 50 | @@ -397,80 +397,80 @@ describe(':terminal mouse', function() ]]) feed(':enew | set number') screen:expect([[ - {7: 1 }^ │line29 | - {4:~ }│line30 | - {4:~ }│rows: 5, cols: 25 | - {4:~ }│rows: 5, cols: 24 | - {4:~ }│ | + {121: 1 }^ │line29 | + {100:~ }│line30 | + {100:~ }│rows: 5, cols: 25 | + {100:~ }│rows: 5, cols: 24 | + {100:~ }│ | ========== ========== | :enew | set number | ]]) feed('30iline\n') screen:expect([[ - {7: 27 }line │line29 | - {7: 28 }line │line30 | - {7: 29 }line │rows: 5, cols: 25 | - {7: 30 }line │rows: 5, cols: 24 | - {7: 31 }^ │ | + {121: 27 }line │line29 | + {121: 28 }line │line30 | + {121: 29 }line │rows: 5, cols: 25 | + {121: 30 }line │rows: 5, cols: 24 | + {121: 31 }^ │ | ========== ========== | | ]]) feed('li') screen:expect([[ - {7: 27 }line │line29 | - {7: 28 }line │line30 | - {7: 29 }line │rows: 5, cols: 25 | - {7: 30 }line │rows: 5, cols: 24 | - {7: 31 } │^ | + {121: 27 }line │line29 | + {121: 28 }line │line30 | + {121: 29 }line │rows: 5, cols: 25 | + {121: 30 }line │rows: 5, cols: 24 | + {121: 31 } │^ | ========== ========== | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- enabling mouse won't affect interaction with other windows tt.enable_mouse() tt.feed_data('mouse enabled\n') screen:expect([[ - {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 } │^ | + {121: 27 }line │line30 | + {121: 28 }line │rows: 5, cols: 25 | + {121: 29 }line │rows: 5, cols: 24 | + {121: 30 }line │mouse enabled | + {121: 31 } │^ | ========== ========== | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) it("scrolling another window keeps focus and respects 'mousescroll'", function() feed('<4,0><4,0>') screen:expect([[ - {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 │^ | + {121: 21 }line │line30 | + {121: 22 }line │rows: 5, cols: 25 | + {121: 23 }line │rows: 5, cols: 24 | + {121: 24 }line │mouse enabled | + {121: 25 }line │^ | ========== ========== | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed('<4,0>') screen:expect([[ - {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 │^ | + {121: 26 }line │line30 | + {121: 27 }line │rows: 5, cols: 25 | + {121: 28 }line │rows: 5, cols: 24 | + {121: 29 }line │mouse enabled | + {121: 30 }line │^ | ========== ========== | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) command('set mousescroll=ver:10') feed('<0,0>') screen:expect([[ - {7: 16 }line │line30 | - {7: 17 }line │rows: 5, cols: 25 | - {7: 18 }line │rows: 5, cols: 24 | - {7: 19 }line │mouse enabled | - {7: 20 }line │^ | + {121: 16 }line │line30 | + {121: 17 }line │rows: 5, cols: 25 | + {121: 18 }line │rows: 5, cols: 24 | + {121: 19 }line │mouse enabled | + {121: 20 }line │^ | ========== ========== | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) command('set mousescroll=ver:0') feed('<0,0>') @@ -479,45 +479,45 @@ describe(':terminal mouse', function() command('setlocal nowrap') feed('0gg3ly$4pwi') screen:expect([[ - {7: 1 }linelinelinelineline │line30 | - {7: 2 }linelinelinelineline │rows: 5, cols: 25 | - {7: 3 }linelinelinelineline │rows: 5, cols: 24 | - {7: 4 }linelinelinelineline │mouse enabled | - {7: 5 }linelinelinelineline │^ | + {121: 1 }linelinelinelineline │line30 | + {121: 2 }linelinelinelineline │rows: 5, cols: 25 | + {121: 3 }linelinelinelineline │rows: 5, cols: 24 | + {121: 4 }linelinelinelineline │mouse enabled | + {121: 5 }linelinelinelineline │^ | ========== ========== | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed('<4,0>') screen:expect([[ - {7: 1 }nelinelineline │line30 | - {7: 2 }nelinelineline │rows: 5, cols: 25 | - {7: 3 }nelinelineline │rows: 5, cols: 24 | - {7: 4 }nelinelineline │mouse enabled | - {7: 5 }nelinelineline │^ | + {121: 1 }nelinelineline │line30 | + {121: 2 }nelinelineline │rows: 5, cols: 25 | + {121: 3 }nelinelineline │rows: 5, cols: 24 | + {121: 4 }nelinelineline │mouse enabled | + {121: 5 }nelinelineline │^ | ========== ========== | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) command('set mousescroll=hor:4') feed('<4,0>') screen:expect([[ - {7: 1 }nelinelinelineline │line30 | - {7: 2 }nelinelinelineline │rows: 5, cols: 25 | - {7: 3 }nelinelinelineline │rows: 5, cols: 24 | - {7: 4 }nelinelinelineline │mouse enabled | - {7: 5 }nelinelinelineline │^ | + {121: 1 }nelinelinelineline │line30 | + {121: 2 }nelinelinelineline │rows: 5, cols: 25 | + {121: 3 }nelinelinelineline │rows: 5, cols: 24 | + {121: 4 }nelinelinelineline │mouse enabled | + {121: 5 }nelinelinelineline │^ | ========== ========== | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) it('will lose focus if another window is clicked', function() feed('<5,1>') screen:expect([[ - {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 } │ | + {121: 27 }line │line30 | + {121: 28 }l^ine │rows: 5, cols: 25 | + {121: 29 }line │rows: 5, cols: 24 | + {121: 30 }line │mouse enabled | + {121: 31 } │ | ========== ========== | | ]]) @@ -527,11 +527,11 @@ describe(':terminal mouse', function() api.nvim_set_option_value('hidden', true, {}) feed('') screen:expect([[ - {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 }^ │ | + {121: 27 }line │line30 | + {121: 28 }line │rows: 5, cols: 25 | + {121: 29 }line │rows: 5, cols: 24 | + {121: 30 }line │mouse enabled | + {121: 31 }^ │ | ========== ========== | | ]]) @@ -547,11 +547,11 @@ describe(':terminal mouse', function() ]]) feed(':bn') screen:expect([[ - {7: 27 }line │rows: 5, cols: 24 | - {7: 28 }line │mouse enabled | - {7: 29 }line │rows: 5, cols: 25 | - {7: 30 }line │rows: 5, cols: 24 | - {7: 31 }^ │ | + {121: 27 }line │rows: 5, cols: 24 | + {121: 28 }line │mouse enabled | + {121: 29 }line │rows: 5, cols: 25 | + {121: 30 }line │rows: 5, cols: 24 | + {121: 31 }^ │ | ========== ========== | :bn | ]]) diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua index a7a383cfbe..8baa88fd25 100644 --- a/test/functional/terminal/scrollback_spec.lua +++ b/test/functional/terminal/scrollback_spec.lua @@ -40,7 +40,7 @@ describe(':terminal scrollback', function() line29 | line30 | ^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -68,7 +68,7 @@ describe(':terminal scrollback', function() line3 | line4 | ^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -85,7 +85,7 @@ describe(':terminal scrollback', function() line4 | line5 | ^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) eq(7, api.nvim_buf_line_count(0)) end) @@ -103,7 +103,7 @@ describe(':terminal scrollback', function() line6 | line7 | line8^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed('6k') @@ -203,7 +203,7 @@ describe(':terminal scrollback', function() rows: 4, cols: 30 | ^ | | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) eq(4, api.nvim_buf_line_count(0)) end @@ -221,7 +221,7 @@ describe(':terminal scrollback', function() rows: 4, cols: 30 | rows: 3, cols: 30 | ^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) eq(4, api.nvim_buf_line_count(0)) feed('gg') @@ -236,7 +236,7 @@ describe(':terminal scrollback', function() rows: 4, cols: 30 | rows: 3, cols: 30 | ^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) end) @@ -253,14 +253,14 @@ describe(':terminal scrollback', function() line3 | line4 | ^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) screen:try_resize(screen._width, screen._height - 3) screen:expect([[ line4 | rows: 3, cols: 30 | ^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) eq(7, api.nvim_buf_line_count(0)) end) @@ -279,7 +279,7 @@ describe(':terminal scrollback', function() rows: 3, cols: 30 | rows: 4, cols: 30 | ^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end @@ -301,7 +301,7 @@ describe(':terminal scrollback', function() rows: 4, cols: 30 | rows: 7, cols: 30 | ^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) eq(9, api.nvim_buf_line_count(0)) feed('gg') @@ -339,7 +339,7 @@ describe(':terminal scrollback', function() rows: 11, cols: 30 | ^ | | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- since there's an empty line after the cursor, the buffer line -- count equals the terminal screen height @@ -355,6 +355,7 @@ describe(':terminal prints more lines than the screen height and exits', functio it('will push extra lines to scrollback', function() clear() local screen = Screen.new(30, 7, { rgb = false }) + screen:add_extra_attr_ids({ [100] = { foreground = 12 } }) command( ("call jobstart(['%s', '10'], {'term':v:true}) | startinsert"):format(testprg('tty-test')) ) @@ -369,14 +370,11 @@ describe(':terminal prints more lines than the screen height and exits', functio ]]) feed('') -- closes the buffer correctly after pressing a key - screen:expect { - grid = [[ + screen:expect([[ ^ | - {1:~ }|*5 + {100:~ }|*5 | - ]], - attr_ids = { [1] = { foreground = 12 } }, - } + ]]) end) end) @@ -449,29 +447,25 @@ describe("'scrollback' option", function() feed_data(('%s REP 41 line%s'):format(testprg('shell-test'), is_os('win') and '\r' or '\n')) if is_os('win') then - screen:expect { - grid = [[ + screen:expect([[ 37: line | 38: line | 39: line | 40: line | | $^ | - {3:-- TERMINAL --} | - ]], - } + {5:-- TERMINAL --} | + ]]) else - screen:expect { - grid = [[ + screen:expect([[ 36: line | 37: line | 38: line | 39: line | 40: line | {MATCH:.*}| - {3:-- TERMINAL --} | - ]], - } + {5:-- TERMINAL --} | + ]]) end expect_lines(58) @@ -496,7 +490,7 @@ describe("'scrollback' option", function() line29 | line30 | ^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) local term_height = 6 -- Actual terminal screen height, not the scrollback -- Initial @@ -581,11 +575,6 @@ describe('pending scrollback line handling', function() before_each(function() clear() screen = Screen.new(30, 7) - screen:set_default_attr_ids { - [1] = { foreground = Screen.colors.Brown }, - [2] = { reverse = true }, - [3] = { bold = true }, - } end) it("does not crash after setting 'number' #14891", function() @@ -598,22 +587,22 @@ describe('pending scrollback line handling', function() api.nvim_win_set_buf(0, buf) ]] screen:expect [[ - {1: 1 }^a | - {1: 2 }a | - {1: 3 }a | - {1: 4 }a | - {1: 5 }a | - {1: 6 }a | + {8: 1 }^a | + {8: 2 }a | + {8: 3 }a | + {8: 4 }a | + {8: 5 }a | + {8: 6 }a | | ]] feed('G') screen:expect [[ - {1: 7 }a | - {1: 8 }a | - {1: 9 }a | - {1: 10 }a | - {1: 11 }a | - {1: 12 }^a | + {8: 7 }a | + {8: 8 }a | + {8: 9 }a | + {8: 10 }a | + {8: 11 }a | + {8: 12 }^a | | ]] assert_alive() @@ -637,7 +626,7 @@ describe('pending scrollback line handling', function() hi |*4 | [Process exited 0]^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]] assert_alive() end) diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua index 2cab1e8006..2e7c0bbcb9 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -51,7 +51,7 @@ describe('TUI', function() ), }) end - screen:expect({ any = vim.pesc('[Process exited 1]') }) + screen:expect({ any = vim.pesc('[Process exited 1]'), unchanged = true }) end) end) @@ -118,10 +118,10 @@ describe('TUI :detach', function() tt.feed_data('iHello, World') screen:expect([[ Hello, World^ | - {4:~ }|*3 - {5:[No Name] [+]{MATCH: *}}{MATCH: *}| - {3:-- INSERT --} | - {3:-- TERMINAL --} | + {100:~ }|*3 + {3:[No Name] [+]{MATCH: *}}{MATCH: *}| + {5:-- INSERT --} | + {5:-- TERMINAL --} | ]]) local child_session = n.connect(child_server) @@ -173,10 +173,10 @@ describe('TUI :detach', function() screen_reattached:expect([[ We did it, pooky^. | - {4:~ }|*3 - {5:[No Name] [+] }| + {100:~ }|*3 + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) end) @@ -225,10 +225,10 @@ describe('TUI :restart', function() local s0 = [[ ^ | - {4:~ }|*3 - {5:[No Name] }| + {100:~ }|*3 + {3:[No Name] }| {MATCH:%d+ +}| - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]] screen_expect(s0) gui_running_check() @@ -253,10 +253,10 @@ describe('TUI :restart', function() end tt.feed_data(':1restart\013') - screen:expect({ any = vim.pesc('{8:E481: No range allowed}') }) + screen:expect({ any = vim.pesc('{101:E481: No range allowed}') }) tt.feed_data(':restart foo\013') - screen:expect({ any = vim.pesc('{8:E488: Trailing characters: foo}') }) + screen:expect({ any = vim.pesc('{101:E488: Trailing characters: foo}') }) -- Check ":restart" on an unmodified buffer. tt.feed_data(':restart\013') @@ -267,22 +267,22 @@ describe('TUI :restart', function() tt.feed_data('ithis will be removed\027') screen_expect([[ this will be remove^d | - {4:~ }|*3 - {5:[No Name] [+] }| + {100:~ }|*3 + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- Check ":restart" on a modified buffer. tt.feed_data(':restart\013') screen_expect([[ this will be removed | - {5: }| - {8:E37: No write since last change} | - {8:E162: No write since last change for buffer "[No N}| - {8:ame]"} | - {10:Press ENTER or type command to continue}^ | - {3:-- TERMINAL --} | + {3: }| + {101:E37: No write since last change} | + {101:E162: No write since last change for buffer "[No N}| + {101:ame]"} | + {102:Press ENTER or type command to continue}^ | + {5:-- TERMINAL --} | ]]) -- Check ":restart!". @@ -300,20 +300,20 @@ describe('TUI :restart', function() screen:try_resize(60, 6) screen_expect([[ ^ | - {4:~ }|*2 - {5:[No Name] }| + {100:~ }|*2 + {3:[No Name] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) --- Check that ":restart" uses the updated size after terminal resize. tt.feed_data(':restart\013') screen_expect([[ ^ | - {4:~ }|*2 - {5:[No Name] }| + {100:~ }|*2 + {3:[No Name] }| {MATCH:%d+ +}| - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) restart_pid_check() gui_running_check() @@ -343,10 +343,10 @@ describe('TUI', function() }) screen:expect([[ ^ | - {4:~ }|*3 - {5:[No Name] }| + {100:~ }|*3 + {3:[No Name] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) child_session = n.connect(child_server) child_exec_lua = tt.make_lua_executor(child_session) @@ -392,9 +392,9 @@ describe('TUI', function() 0001;;Cc;0;BN;;;;;N;START OF HEADING;;;; | 0002;;Cc;0;BN;;;;;N;START OF TEXT;;;; | 0003;;Cc;0;BN;;;;;N;END OF TEXT;;;; | - {5:test/functional/fixtures/bigfile.txt }| + {3:test/functional/fixtures/bigfile.txt }| :edit test/functional/fixtures/bigfile.txt | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) command('call jobresize(b:terminal_job_id, 58, 9)') command('call jobresize(b:terminal_job_id, 62, 13)') @@ -432,107 +432,93 @@ describe('TUI', function() ) feed_data(':call ManyErr()\r') screen:expect([[ - {8:Error in function ManyErr:} | - {11:line 2:} | - {8:FAIL 0} | - {8:FAIL 1} | - {8:FAIL 2} | - {10:-- More --}^ | - {3:-- TERMINAL --} | + {101:Error in function ManyErr:} | + {103:line 2:} | + {101:FAIL 0} | + {101:FAIL 1} | + {101:FAIL 2} | + {102:-- More --}^ | + {5:-- TERMINAL --} | ]]) screen:try_resize(50, 10) - screen:expect { - grid = [[ + screen:expect([[ :call ManyErr() | - {8:Error in function ManyErr:} | - {11:line 2:} | - {8:FAIL 0} | - {8:FAIL 1} | - {8:FAIL 2} | + {101:Error in function ManyErr:} | + {103:line 2:} | + {101:FAIL 0} | + {101:FAIL 1} | + {101:FAIL 2} | |*2 - {10:-- More --}^ | - {3:-- TERMINAL --} | - ]], - } + {102:-- More --}^ | + {5:-- TERMINAL --} | + ]]) feed_data('j') - screen:expect { - grid = [[ - {8:Error in function ManyErr:} | - {11:line 2:} | - {8:FAIL 0} | - {8:FAIL 1} | - {8:FAIL 2} | - {8:FAIL 3} | - {8:FAIL 4} | - {8:FAIL 5} | - {10:-- More --}^ | - {3:-- TERMINAL --} | - ]], - } + screen:expect([[ + {101:Error in function ManyErr:} | + {103:line 2:} | + {101:FAIL 0} | + {101:FAIL 1} | + {101:FAIL 2} | + {101:FAIL 3} | + {101:FAIL 4} | + {101:FAIL 5} | + {102:-- More --}^ | + {5:-- TERMINAL --} | + ]]) screen:try_resize(50, 7) - screen:expect { - grid = [[ - {8:FAIL 1} | - {8:FAIL 2} | - {8:FAIL 3} | - {8:FAIL 4} | - {8:FAIL 5} | - {10:-- More --}^ | - {3:-- TERMINAL --} | - ]], - } + screen:expect([[ + {101:FAIL 1} | + {101:FAIL 2} | + {101:FAIL 3} | + {101:FAIL 4} | + {101:FAIL 5} | + {102:-- More --}^ | + {5:-- TERMINAL --} | + ]]) screen:try_resize(50, 5) - screen:expect { - grid = [[ - {8:FAIL 3} | - {8:FAIL 4} | - {8:FAIL 5} | - {10:-- More --}^ | - {3:-- TERMINAL --} | - ]], - } + screen:expect([[ + {101:FAIL 3} | + {101:FAIL 4} | + {101:FAIL 5} | + {102:-- More --}^ | + {5:-- TERMINAL --} | + ]]) feed_data('g') - screen:expect { - grid = [[ + screen:expect([[ :call ManyErr() | - {8:Error in function ManyErr:} | - {11:line 2:} | - {10:-- More --}^ | - {3:-- TERMINAL --} | - ]], - } + {101:Error in function ManyErr:} | + {103:line 2:} | + {102:-- More --}^ | + {5:-- TERMINAL --} | + ]]) screen:try_resize(50, 10) - screen:expect { - grid = [[ + screen:expect([[ :call ManyErr() | - {8:Error in function ManyErr:} | - {11:line 2:} | - {8:FAIL 0} | - {8:FAIL 1} | - {8:FAIL 2} | - {8:FAIL 3} | - {8:FAIL 4} | - {10:-- More --}^ | - {3:-- TERMINAL --} | - ]], - } + {101:Error in function ManyErr:} | + {103:line 2:} | + {101:FAIL 0} | + {101:FAIL 1} | + {101:FAIL 2} | + {101:FAIL 3} | + {101:FAIL 4} | + {102:-- More --}^ | + {5:-- TERMINAL --} | + ]]) feed_data('\003') - screen:expect { - grid = [[ + screen:expect([[ ^ | - {4:~ }|*6 - {5:[No Name] }| + {100:~ }|*6 + {3:[No Name] }| | - {3:-- TERMINAL --} | - ]], - } + {5:-- TERMINAL --} | + ]]) end) it('accepts basic utf-8 input', function() @@ -541,20 +527,20 @@ describe('TUI', function() abc | test1 | test2^ | - {4:~ }| - {5:[No Name] [+] }| - {3:-- INSERT --} | - {3:-- TERMINAL --} | + {100:~ }| + {3:[No Name] [+] }| + {5:-- INSERT --} | + {5:-- TERMINAL --} | ]]) feed_data('\027') screen:expect([[ abc | test1 | test^2 | - {4:~ }| - {5:[No Name] [+] }| + {100:~ }| + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -569,9 +555,9 @@ describe('TUI', function() alt-k | alt-l | ^ | - {5:[No Name] [+] }| + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed_data('gg') screen:expect([[ @@ -579,9 +565,9 @@ describe('TUI', function() alt-f | alt-g | alt-h | - {5:[No Name] [+] }| + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -591,10 +577,10 @@ describe('TUI', function() feed_data('i\022\027j') screen:expect([[ ^ | - {4:~ }|*3 - {5:[No Name] [+] }| - {3:-- INSERT --} | - {3:-- TERMINAL --} | + {100:~ }|*3 + {3:[No Name] [+] }| + {5:-- INSERT --} | + {5:-- TERMINAL --} | ]]) end) @@ -624,10 +610,10 @@ describe('TUI', function() expect_child_buf_lines({ 'ESCsemicolonCtrlEscSuperEscESC' }) screen:expect([[ ESCsemicolonCtrlEscSuperEscES^C | - {4:~ }|*3 - {5:[No Name] [+] }| + {100:~ }|*3 + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- ; should be recognized as when is mapped feed_data('\027;') @@ -639,10 +625,10 @@ describe('TUI', function() feed_data('i\022\027\000') screen:expect([[ ^ | - {4:~ }|*3 - {5:[No Name] [+] }| - {3:-- INSERT --} | - {3:-- TERMINAL --} | + {100:~ }|*3 + {3:[No Name] [+] }| + {5:-- INSERT --} | + {5:-- TERMINAL --} | ]]) end) @@ -652,20 +638,20 @@ describe('TUI', function() feed_data('\022\022') -- ctrl+v feed_data('\022\013') -- ctrl+m screen:expect([[ - {6:^G^V^M}^ | - {4:~ }|*3 - {5:[No Name] [+] }| - {3:-- INSERT --} | - {3:-- TERMINAL --} | + {104:^G^V^M}^ | + {100:~ }|*3 + {3:[No Name] [+] }| + {5:-- INSERT --} | + {5:-- TERMINAL --} | ]]) child_session:request('nvim_set_keymap', 'i', '\031', '!!!', {}) feed_data('\031') screen:expect([[ - {6:^G^V^M}!!!^ | - {4:~ }|*3 - {5:[No Name] [+] }| - {3:-- INSERT --} | - {3:-- TERMINAL --} | + {104:^G^V^M}!!!^ | + {100:~ }|*3 + {3:[No Name] [+] }| + {5:-- INSERT --} | + {5:-- TERMINAL --} | ]]) child_session:request('nvim_buf_delete', 0, { force = true }) child_session:request('nvim_set_option_value', 'laststatus', 0, {}) @@ -677,18 +663,18 @@ describe('TUI', function() screen:expect([[ interact $ ^ | |*4 - {3:-- TERMINAL --} |*2 + {5:-- TERMINAL --} |*2 ]]) -- mappings for C0 control codes should work in Terminal mode #33750 child_session:request('nvim_set_keymap', 't', '\031', 'new', {}) feed_data('\031') screen:expect([[ ^ | - {4:~ }| - {5:[No Name] }| + {100:~ }| + {3:[No Name] }| interact $ | |*2 - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -703,13 +689,13 @@ describe('TUI', function() {} ) screen:expect([[ - {11: 1 }^0----1----2----3----4│{11: 1 }0----1----2----3----| - {11: 2 }0----1----2----3----4│{11: 2 }0----1----2----3----| - {11: 3 }0----1----2----3----4│{11: 3 }0----1----2----3----| - {11: 4 }0----1----2----3----4│{11: 4 }0----1----2----3----| - {5:[No Name] [+] }{1:[No Name] [+] }| + {103: 1 }^0----1----2----3----4│{103: 1 }0----1----2----3----| + {103: 2 }0----1----2----3----4│{103: 2 }0----1----2----3----| + {103: 3 }0----1----2----3----4│{103: 3 }0----1----2----3----| + {103: 4 }0----1----2----3----4│{103: 4 }0----1----2----3----| + {3:[No Name] [+] }{2:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- in active window if esc then @@ -718,13 +704,13 @@ describe('TUI', function() api.nvim_input_mouse('wheel', 'down', '', 0, 0, 7) end screen:expect([[ - {11: 2 }^0----1----2----3----4│{11: 1 }0----1----2----3----| - {11: 3 }0----1----2----3----4│{11: 2 }0----1----2----3----| - {11: 4 }0----1----2----3----4│{11: 3 }0----1----2----3----| - {11: 5 }0----1----2----3----4│{11: 4 }0----1----2----3----| - {5:[No Name] [+] }{1:[No Name] [+] }| + {103: 2 }^0----1----2----3----4│{103: 1 }0----1----2----3----| + {103: 3 }0----1----2----3----4│{103: 2 }0----1----2----3----| + {103: 4 }0----1----2----3----4│{103: 3 }0----1----2----3----| + {103: 5 }0----1----2----3----4│{103: 4 }0----1----2----3----| + {3:[No Name] [+] }{2:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- in inactive window if esc then @@ -733,13 +719,13 @@ describe('TUI', function() api.nvim_input_mouse('wheel', 'down', '', 0, 0, 47) end screen:expect([[ - {11: 2 }^0----1----2----3----4│{11: 2 }0----1----2----3----| - {11: 3 }0----1----2----3----4│{11: 3 }0----1----2----3----| - {11: 4 }0----1----2----3----4│{11: 4 }0----1----2----3----| - {11: 5 }0----1----2----3----4│{11: 5 }0----1----2----3----| - {5:[No Name] [+] }{1:[No Name] [+] }| + {103: 2 }^0----1----2----3----4│{103: 2 }0----1----2----3----| + {103: 3 }0----1----2----3----4│{103: 3 }0----1----2----3----| + {103: 4 }0----1----2----3----4│{103: 4 }0----1----2----3----| + {103: 5 }0----1----2----3----4│{103: 5 }0----1----2----3----| + {3:[No Name] [+] }{2:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- in active window if esc then @@ -748,13 +734,13 @@ describe('TUI', function() api.nvim_input_mouse('wheel', 'right', '', 0, 0, 7) end screen:expect([[ - {11: 2 }^----1----2----3----4-│{11: 2 }0----1----2----3----| - {11: 3 }----1----2----3----4-│{11: 3 }0----1----2----3----| - {11: 4 }----1----2----3----4-│{11: 4 }0----1----2----3----| - {11: 5 }----1----2----3----4-│{11: 5 }0----1----2----3----| - {5:[No Name] [+] }{1:[No Name] [+] }| + {103: 2 }^----1----2----3----4-│{103: 2 }0----1----2----3----| + {103: 3 }----1----2----3----4-│{103: 3 }0----1----2----3----| + {103: 4 }----1----2----3----4-│{103: 4 }0----1----2----3----| + {103: 5 }----1----2----3----4-│{103: 5 }0----1----2----3----| + {3:[No Name] [+] }{2:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- in inactive window if esc then @@ -763,13 +749,13 @@ describe('TUI', function() api.nvim_input_mouse('wheel', 'right', '', 0, 0, 47) end screen:expect([[ - {11: 2 }^----1----2----3----4-│{11: 2 }----1----2----3----4| - {11: 3 }----1----2----3----4-│{11: 3 }----1----2----3----4| - {11: 4 }----1----2----3----4-│{11: 4 }----1----2----3----4| - {11: 5 }----1----2----3----4-│{11: 5 }----1----2----3----4| - {5:[No Name] [+] }{1:[No Name] [+] }| + {103: 2 }^----1----2----3----4-│{103: 2 }----1----2----3----4| + {103: 3 }----1----2----3----4-│{103: 3 }----1----2----3----4| + {103: 4 }----1----2----3----4-│{103: 4 }----1----2----3----4| + {103: 5 }----1----2----3----4-│{103: 5 }----1----2----3----4| + {3:[No Name] [+] }{2:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- in active window if esc then @@ -778,13 +764,13 @@ describe('TUI', function() api.nvim_input_mouse('wheel', 'down', 'S', 0, 0, 7) end screen:expect([[ - {11: 5 }^----1----2----3----4-│{11: 2 }----1----2----3----4| - {11: 6 }----1----2----3----4-│{11: 3 }----1----2----3----4| - {11: 7 }----1----2----3----4-│{11: 4 }----1----2----3----4| - {11: 8 }----1----2----3----4-│{11: 5 }----1----2----3----4| - {5:[No Name] [+] }{1:[No Name] [+] }| + {103: 5 }^----1----2----3----4-│{103: 2 }----1----2----3----4| + {103: 6 }----1----2----3----4-│{103: 3 }----1----2----3----4| + {103: 7 }----1----2----3----4-│{103: 4 }----1----2----3----4| + {103: 8 }----1----2----3----4-│{103: 5 }----1----2----3----4| + {3:[No Name] [+] }{2:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- in inactive window if esc then @@ -793,13 +779,13 @@ describe('TUI', function() api.nvim_input_mouse('wheel', 'down', 'S', 0, 0, 47) end screen:expect([[ - {11: 5 }^----1----2----3----4-│{11: 5 }----1----2----3----4| - {11: 6 }----1----2----3----4-│{11: 6 }----1----2----3----4| - {11: 7 }----1----2----3----4-│{11: 7 }----1----2----3----4| - {11: 8 }----1----2----3----4-│{11: 8 }----1----2----3----4| - {5:[No Name] [+] }{1:[No Name] [+] }| + {103: 5 }^----1----2----3----4-│{103: 5 }----1----2----3----4| + {103: 6 }----1----2----3----4-│{103: 6 }----1----2----3----4| + {103: 7 }----1----2----3----4-│{103: 7 }----1----2----3----4| + {103: 8 }----1----2----3----4-│{103: 8 }----1----2----3----4| + {3:[No Name] [+] }{2:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- in active window if esc then @@ -808,13 +794,13 @@ describe('TUI', function() api.nvim_input_mouse('wheel', 'right', 'S', 0, 0, 7) end screen:expect([[ - {11: 5 }^----6----7----8----9 │{11: 5 }----1----2----3----4| - {11: 6 }----6----7----8----9 │{11: 6 }----1----2----3----4| - {11: 7 }----6----7----8----9 │{11: 7 }----1----2----3----4| - {11: 8 }----6----7----8----9 │{11: 8 }----1----2----3----4| - {5:[No Name] [+] }{1:[No Name] [+] }| + {103: 5 }^----6----7----8----9 │{103: 5 }----1----2----3----4| + {103: 6 }----6----7----8----9 │{103: 6 }----1----2----3----4| + {103: 7 }----6----7----8----9 │{103: 7 }----1----2----3----4| + {103: 8 }----6----7----8----9 │{103: 8 }----1----2----3----4| + {3:[No Name] [+] }{2:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- in inactive window if esc then @@ -823,13 +809,13 @@ describe('TUI', function() api.nvim_input_mouse('wheel', 'right', 'S', 0, 0, 47) end screen:expect([[ - {11: 5 }^----6----7----8----9 │{11: 5 }5----6----7----8----| - {11: 6 }----6----7----8----9 │{11: 6 }5----6----7----8----| - {11: 7 }----6----7----8----9 │{11: 7 }5----6----7----8----| - {11: 8 }----6----7----8----9 │{11: 8 }5----6----7----8----| - {5:[No Name] [+] }{1:[No Name] [+] }| + {103: 5 }^----6----7----8----9 │{103: 5 }5----6----7----8----| + {103: 6 }----6----7----8----9 │{103: 6 }5----6----7----8----| + {103: 7 }----6----7----8----9 │{103: 7 }5----6----7----8----| + {103: 8 }----6----7----8----9 │{103: 8 }5----6----7----8----| + {3:[No Name] [+] }{2:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- in active window if esc then @@ -838,13 +824,13 @@ describe('TUI', function() api.nvim_input_mouse('wheel', 'up', '', 0, 0, 7) end screen:expect([[ - {11: 4 }----6----7----8----9 │{11: 5 }5----6----7----8----| - {11: 5 }^----6----7----8----9 │{11: 6 }5----6----7----8----| - {11: 6 }----6----7----8----9 │{11: 7 }5----6----7----8----| - {11: 7 }----6----7----8----9 │{11: 8 }5----6----7----8----| - {5:[No Name] [+] }{1:[No Name] [+] }| + {103: 4 }----6----7----8----9 │{103: 5 }5----6----7----8----| + {103: 5 }^----6----7----8----9 │{103: 6 }5----6----7----8----| + {103: 6 }----6----7----8----9 │{103: 7 }5----6----7----8----| + {103: 7 }----6----7----8----9 │{103: 8 }5----6----7----8----| + {3:[No Name] [+] }{2:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- in inactive window if esc then @@ -853,13 +839,13 @@ describe('TUI', function() api.nvim_input_mouse('wheel', 'up', '', 0, 0, 47) end screen:expect([[ - {11: 4 }----6----7----8----9 │{11: 4 }5----6----7----8----| - {11: 5 }^----6----7----8----9 │{11: 5 }5----6----7----8----| - {11: 6 }----6----7----8----9 │{11: 6 }5----6----7----8----| - {11: 7 }----6----7----8----9 │{11: 7 }5----6----7----8----| - {5:[No Name] [+] }{1:[No Name] [+] }| + {103: 4 }----6----7----8----9 │{103: 4 }5----6----7----8----| + {103: 5 }^----6----7----8----9 │{103: 5 }5----6----7----8----| + {103: 6 }----6----7----8----9 │{103: 6 }5----6----7----8----| + {103: 7 }----6----7----8----9 │{103: 7 }5----6----7----8----| + {3:[No Name] [+] }{2:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- in active window if esc then @@ -868,13 +854,13 @@ describe('TUI', function() api.nvim_input_mouse('wheel', 'left', '', 0, 0, 7) end screen:expect([[ - {11: 4 }5----6----7----8----9│{11: 4 }5----6----7----8----| - {11: 5 }5^----6----7----8----9│{11: 5 }5----6----7----8----| - {11: 6 }5----6----7----8----9│{11: 6 }5----6----7----8----| - {11: 7 }5----6----7----8----9│{11: 7 }5----6----7----8----| - {5:[No Name] [+] }{1:[No Name] [+] }| + {103: 4 }5----6----7----8----9│{103: 4 }5----6----7----8----| + {103: 5 }5^----6----7----8----9│{103: 5 }5----6----7----8----| + {103: 6 }5----6----7----8----9│{103: 6 }5----6----7----8----| + {103: 7 }5----6----7----8----9│{103: 7 }5----6----7----8----| + {3:[No Name] [+] }{2:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- in inactive window if esc then @@ -883,13 +869,13 @@ describe('TUI', function() api.nvim_input_mouse('wheel', 'left', '', 0, 0, 47) end screen:expect([[ - {11: 4 }5----6----7----8----9│{11: 4 }-5----6----7----8---| - {11: 5 }5^----6----7----8----9│{11: 5 }-5----6----7----8---| - {11: 6 }5----6----7----8----9│{11: 6 }-5----6----7----8---| - {11: 7 }5----6----7----8----9│{11: 7 }-5----6----7----8---| - {5:[No Name] [+] }{1:[No Name] [+] }| + {103: 4 }5----6----7----8----9│{103: 4 }-5----6----7----8---| + {103: 5 }5^----6----7----8----9│{103: 5 }-5----6----7----8---| + {103: 6 }5----6----7----8----9│{103: 6 }-5----6----7----8---| + {103: 7 }5----6----7----8----9│{103: 7 }-5----6----7----8---| + {3:[No Name] [+] }{2:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- in active window if esc then @@ -898,13 +884,13 @@ describe('TUI', function() api.nvim_input_mouse('wheel', 'up', 'S', 0, 0, 7) end screen:expect([[ - {11: 1 }5----6----7----8----9│{11: 4 }-5----6----7----8---| - {11: 2 }5----6----7----8----9│{11: 5 }-5----6----7----8---| - {11: 3 }5----6----7----8----9│{11: 6 }-5----6----7----8---| - {11: 4 }5^----6----7----8----9│{11: 7 }-5----6----7----8---| - {5:[No Name] [+] }{1:[No Name] [+] }| + {103: 1 }5----6----7----8----9│{103: 4 }-5----6----7----8---| + {103: 2 }5----6----7----8----9│{103: 5 }-5----6----7----8---| + {103: 3 }5----6----7----8----9│{103: 6 }-5----6----7----8---| + {103: 4 }5^----6----7----8----9│{103: 7 }-5----6----7----8---| + {3:[No Name] [+] }{2:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- in inactive window if esc then @@ -913,13 +899,13 @@ describe('TUI', function() api.nvim_input_mouse('wheel', 'up', 'S', 0, 0, 47) end screen:expect([[ - {11: 1 }5----6----7----8----9│{11: 1 }-5----6----7----8---| - {11: 2 }5----6----7----8----9│{11: 2 }-5----6----7----8---| - {11: 3 }5----6----7----8----9│{11: 3 }-5----6----7----8---| - {11: 4 }5^----6----7----8----9│{11: 4 }-5----6----7----8---| - {5:[No Name] [+] }{1:[No Name] [+] }| + {103: 1 }5----6----7----8----9│{103: 1 }-5----6----7----8---| + {103: 2 }5----6----7----8----9│{103: 2 }-5----6----7----8---| + {103: 3 }5----6----7----8----9│{103: 3 }-5----6----7----8---| + {103: 4 }5^----6----7----8----9│{103: 4 }-5----6----7----8---| + {3:[No Name] [+] }{2:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- in active window if esc then @@ -928,13 +914,13 @@ describe('TUI', function() api.nvim_input_mouse('wheel', 'left', 'S', 0, 0, 7) end screen:expect([[ - {11: 1 }0----1----2----3----4│{11: 1 }-5----6----7----8---| - {11: 2 }0----1----2----3----4│{11: 2 }-5----6----7----8---| - {11: 3 }0----1----2----3----4│{11: 3 }-5----6----7----8---| - {11: 4 }0----1----2----3----^4│{11: 4 }-5----6----7----8---| - {5:[No Name] [+] }{1:[No Name] [+] }| + {103: 1 }0----1----2----3----4│{103: 1 }-5----6----7----8---| + {103: 2 }0----1----2----3----4│{103: 2 }-5----6----7----8---| + {103: 3 }0----1----2----3----4│{103: 3 }-5----6----7----8---| + {103: 4 }0----1----2----3----^4│{103: 4 }-5----6----7----8---| + {3:[No Name] [+] }{2:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- in inactive window if esc then @@ -943,13 +929,13 @@ describe('TUI', function() api.nvim_input_mouse('wheel', 'left', 'S', 0, 0, 47) end screen:expect([[ - {11: 1 }0----1----2----3----4│{11: 1 }0----1----2----3----| - {11: 2 }0----1----2----3----4│{11: 2 }0----1----2----3----| - {11: 3 }0----1----2----3----4│{11: 3 }0----1----2----3----| - {11: 4 }0----1----2----3----^4│{11: 4 }0----1----2----3----| - {5:[No Name] [+] }{1:[No Name] [+] }| + {103: 1 }0----1----2----3----4│{103: 1 }0----1----2----3----| + {103: 2 }0----1----2----3----4│{103: 2 }0----1----2----3----| + {103: 3 }0----1----2----3----4│{103: 3 }0----1----2----3----| + {103: 4 }0----1----2----3----^4│{103: 4 }0----1----2----3----| + {3:[No Name] [+] }{2:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end @@ -988,12 +974,12 @@ describe('TUI', function() end screen:expect([[ ^popup menu test | - {4:~ }{13: foo }{4: }| - {4:~ }{13: bar }{4: }| - {4:~ }{13: baz }{4: }| - {5:[No Name] [+] }| + {100:~ }{105: foo }{100: }| + {100:~ }{105: bar }{100: }| + {100:~ }{105: baz }{100: }| + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) if esc then feed_data('\027[<2;5;1m') @@ -1008,12 +994,12 @@ describe('TUI', function() end screen:expect([[ ^popup menu test | - {4:~ }{14: foo }{4: }| - {4:~ }{13: bar }{4: }| - {4:~ }{13: baz }{4: }| - {5:[No Name] [+] }| + {100:~ }{106: foo }{100: }| + {100:~ }{105: bar }{100: }| + {100:~ }{105: baz }{100: }| + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) if esc then feed_data('\027[<35;7;4M') @@ -1022,12 +1008,12 @@ describe('TUI', function() end screen:expect([[ ^popup menu test | - {4:~ }{13: foo }{4: }| - {4:~ }{13: bar }{4: }| - {4:~ }{14: baz }{4: }| - {5:[No Name] [+] }| + {100:~ }{105: foo }{100: }| + {100:~ }{105: bar }{100: }| + {100:~ }{106: baz }{100: }| + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) if esc then feed_data('\027[<65;7;4M') @@ -1036,12 +1022,12 @@ describe('TUI', function() end screen:expect([[ ^popup menu test | - {4:~ }{13: foo }{4: }| - {4:~ }{14: bar }{4: }| - {4:~ }{13: baz }{4: }| - {5:[No Name] [+] }| + {100:~ }{105: foo }{100: }| + {100:~ }{106: bar }{100: }| + {100:~ }{105: baz }{100: }| + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) if esc then feed_data('\027[<0;7;3M') @@ -1050,10 +1036,10 @@ describe('TUI', function() end screen:expect([[ ^popup menu test | - {4:~ }|*3 - {5:[No Name] [+] }| + {100:~ }|*3 + {3:[No Name] [+] }| :let g:menustr = 'bar' | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) if esc then feed_data('\027[<0;7;3m') @@ -1068,11 +1054,11 @@ describe('TUI', function() end screen:expect([[ ^popup menu test | - {4:~ }|*2 - {4:~ }{13: foo }{4: }| - {5:[No Name] [+] }{13: bar }{5: }| - :let g:menustr = 'bar' {13: baz } | - {3:-- TERMINAL --} | + {100:~ }|*2 + {100:~ }{105: foo }{100: }| + {3:[No Name] [+] }{105: bar }{3: }| + :let g:menustr = 'bar' {105: baz } | + {5:-- TERMINAL --} | ]]) if esc then feed_data('\027[<34;48;6M') @@ -1081,11 +1067,11 @@ describe('TUI', function() end screen:expect([[ ^popup menu test | - {4:~ }|*2 - {4:~ }{13: foo }{4: }| - {5:[No Name] [+] }{13: bar }{5: }| - :let g:menustr = 'bar' {14: baz } | - {3:-- TERMINAL --} | + {100:~ }|*2 + {100:~ }{105: foo }{100: }| + {3:[No Name] [+] }{105: bar }{3: }| + :let g:menustr = 'bar' {106: baz } | + {5:-- TERMINAL --} | ]]) if esc then feed_data('\027[<2;48;6m') @@ -1094,10 +1080,10 @@ describe('TUI', function() end screen:expect([[ ^popup menu test | - {4:~ }|*3 - {5:[No Name] [+] }| + {100:~ }|*3 + {3:[No Name] [+] }| :let g:menustr = 'baz' | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end @@ -1133,109 +1119,109 @@ describe('TUI', function() screen:expect([[ 0123456789./*-+ | =^ | - {4:~ }|*2 - {5:[No Name] [+] }| - {3:-- INSERT --} | - {3:-- TERMINAL --} | + {100:~ }|*2 + {3:[No Name] [+] }| + {5:-- INSERT --} | + {5:-- TERMINAL --} | ]]) feed_data(fn.nr2char(57417)) -- KP_LEFT screen:expect([[ 0123456789./*-+ | ^= | - {4:~ }|*2 - {5:[No Name] [+] }| - {3:-- INSERT --} | - {3:-- TERMINAL --} | + {100:~ }|*2 + {3:[No Name] [+] }| + {5:-- INSERT --} | + {5:-- TERMINAL --} | ]]) feed_data(fn.nr2char(57418)) -- KP_RIGHT screen:expect([[ 0123456789./*-+ | =^ | - {4:~ }|*2 - {5:[No Name] [+] }| - {3:-- INSERT --} | - {3:-- TERMINAL --} | + {100:~ }|*2 + {3:[No Name] [+] }| + {5:-- INSERT --} | + {5:-- TERMINAL --} | ]]) feed_data(fn.nr2char(57419)) -- KP_UP screen:expect([[ 0^123456789./*-+ | = | - {4:~ }|*2 - {5:[No Name] [+] }| - {3:-- INSERT --} | - {3:-- TERMINAL --} | + {100:~ }|*2 + {3:[No Name] [+] }| + {5:-- INSERT --} | + {5:-- TERMINAL --} | ]]) feed_data(fn.nr2char(57420)) -- KP_DOWN screen:expect([[ 0123456789./*-+ | =^ | - {4:~ }|*2 - {5:[No Name] [+] }| - {3:-- INSERT --} | - {3:-- TERMINAL --} | + {100:~ }|*2 + {3:[No Name] [+] }| + {5:-- INSERT --} | + {5:-- TERMINAL --} | ]]) feed_data(fn.nr2char(57425)) -- KP_INSERT screen:expect([[ 0123456789./*-+ | =^ | - {4:~ }|*2 - {5:[No Name] [+] }| - {3:-- REPLACE --} | - {3:-- TERMINAL --} | + {100:~ }|*2 + {3:[No Name] [+] }| + {5:-- REPLACE --} | + {5:-- TERMINAL --} | ]]) feed_data('\027[27u') -- ESC screen:expect([[ 0123456789./*-+ | ^= | - {4:~ }|*2 - {5:[No Name] [+] }| + {100:~ }|*2 + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed_data('\027[57417;5u') -- CTRL + KP_LEFT screen:expect([[ ^0123456789./*-+ | = | - {4:~ }|*2 - {5:[No Name] [+] }| + {100:~ }|*2 + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed_data('\027[57418;2u') -- SHIFT + KP_RIGHT screen:expect([[ 0123456789^./*-+ | = | - {4:~ }|*2 - {5:[No Name] [+] }| + {100:~ }|*2 + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed_data(fn.nr2char(57426)) -- KP_DELETE screen:expect([[ 0123456789^/*-+ | = | - {4:~ }|*2 - {5:[No Name] [+] }| + {100:~ }|*2 + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed_data(fn.nr2char(57423)) -- KP_HOME screen:expect([[ ^0123456789/*-+ | = | - {4:~ }|*2 - {5:[No Name] [+] }| + {100:~ }|*2 + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed_data(fn.nr2char(57424)) -- KP_END screen:expect([[ 0123456789/*-^+ | = | - {4:~ }|*2 - {5:[No Name] [+] }| + {100:~ }|*2 + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) child_session:request( 'nvim_exec2', @@ -1247,31 +1233,31 @@ describe('TUI', function() {} ) screen:expect([[ - {12: + [No Name] + [No Name] }{3: [No Name] }{1: }{12:X}| + {107: + [No Name] + [No Name] }{5: [No Name] }{2: }{107:X}| ^ | - {4:~ }|*2 - {5:[No Name] }| + {100:~ }|*2 + {3:[No Name] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed_data('\027[57421;5u') -- CTRL + KP_PAGE_UP screen:expect([[ - {12: + [No Name] }{3: + [No Name] }{12: [No Name] }{1: }{12:X}| + {107: + [No Name] }{5: + [No Name] }{107: [No Name] }{2: }{107:X}| 0123456789/*-^+ | = | - {4:~ }| - {5:[No Name] [+] }| + {100:~ }| + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed_data('\027[57422;5u') -- CTRL + KP_PAGE_DOWN screen:expect([[ - {12: + [No Name] + [No Name] }{3: [No Name] }{1: }{12:X}| + {107: + [No Name] + [No Name] }{5: [No Name] }{2: }{107:X}| ^ | - {4:~ }|*2 - {5:[No Name] }| + {100:~ }|*2 + {3:[No Name] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -1289,10 +1275,10 @@ describe('TUI', function() screen:expect([[ | ^ | - {4:~ }|*2 - {5:[No Name] [+] }| - {3:-- INSERT --} | - {3:-- TERMINAL --} | + {100:~ }|*2 + {3:[No Name] [+] }| + {5:-- INSERT --} | + {5:-- TERMINAL --} | ]]) end) @@ -1301,19 +1287,19 @@ describe('TUI', function() feed_data('i""\027i\027[200~') screen:expect([[ "^" | - {4:~ }|*3 - {5:[No Name] [+] }| - {3:-- INSERT --} | - {3:-- TERMINAL --} | + {100:~ }|*3 + {3:[No Name] [+] }| + {5:-- INSERT --} | + {5:-- TERMINAL --} | ]]) feed_data('pasted from terminal') expect_child_buf_lines({ '"pasted from terminal"' }) screen:expect([[ "pasted from terminal^" | - {4:~ }|*3 - {5:[No Name] [+] }| - {3:-- INSERT --} | - {3:-- TERMINAL --} | + {100:~ }|*3 + {3:[No Name] [+] }| + {5:-- INSERT --} | + {5:-- TERMINAL --} | ]]) feed_data('\027[201~') -- End paste. poke_both_eventloop() @@ -1322,10 +1308,10 @@ describe('TUI', function() wait_for_mode('n') screen:expect([[ "pasted from termina^l" | - {4:~ }|*3 - {5:[No Name] [+] }| + {100:~ }|*3 + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- Dot-repeat/redo. feed_data('2.') @@ -1333,10 +1319,10 @@ describe('TUI', function() screen:expect([[ "pasted from terminapasted from terminalpasted fro| m termina^ll" | - {4:~ }|*2 - {5:[No Name] [+] }| + {100:~ }|*2 + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- Undo. feed_data('u') @@ -1355,20 +1341,20 @@ describe('TUI', function() this is line 2 | line 3 is here | ^ | - {5:[No Name] [+] }| + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- Select-mode. Use to move down. feed_data('gg04lgh\14\14') screen:expect([[ - this{16: is line 1} | - {16:this is line 2} | - {16:line}^ 3 is here | + this{108: is line 1} | + {108:this is line 2} | + {108:line}^ 3 is here | | - {5:[No Name] [+] }| - {3:-- SELECT --} | - {3:-- TERMINAL --} | + {3:[No Name] [+] }| + {5:-- SELECT --} | + {5:-- TERMINAL --} | ]]) feed_data('\027[200~') feed_data('just paste it™') @@ -1376,10 +1362,10 @@ describe('TUI', function() screen:expect([[ thisjust paste it^™3 is here | | - {4:~ }|*2 - {5:[No Name] [+] }| + {100:~ }|*2 + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- Undo. feed_data('u') @@ -1401,10 +1387,6 @@ describe('TUI', function() if is_ci('github') then pending('tty-test complains about not owning the terminal -- actions/runner#241') end - screen:set_default_attr_ids({ - [3] = { bold = true }, - [19] = { bold = true, background = 121, foreground = 0 }, -- StatusLineTerm - }) child_exec_lua('vim.o.statusline="^^^^^^^"') child_exec_lua('vim.cmd.terminal(...)', testprg('tty-test')) feed_data('i') @@ -1412,8 +1394,8 @@ describe('TUI', function() tty ready | ^ | |*2 - {19:^^^^^^^ }| - {3:-- TERMINAL --} |*2 + {109:^^^^^^^ }| + {5:-- TERMINAL --} |*2 ]]) feed_data('\027[200~') feed_data('hallo') @@ -1422,8 +1404,8 @@ describe('TUI', function() tty ready | hallo^ | |*2 - {19:^^^^^^^ }| - {3:-- TERMINAL --} |*2 + {109:^^^^^^^ }| + {5:-- TERMINAL --} |*2 ]]) end) @@ -1436,12 +1418,12 @@ describe('TUI', function() local expected_crlf = { 'line 1', 'ESC:\027 / CR: ', 'x' } local expected_grid1 = [[ line 1 | - ESC:{6:^[} / CR: | + ESC:{104:^[} / CR: | ^x | - {4:~ }| - {5:[No Name] [+] 3,1 All}| + {100:~ }| + {3:[No Name] [+] 3,1 All}| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]] -- "bracketed paste" feed_data('\027[200~' .. table.concat(expected_lf, '\n') .. '\027[201~') @@ -1449,13 +1431,13 @@ describe('TUI', function() -- Dot-repeat/redo. feed_data('.') local expected_grid2 = [[ - ESC:{6:^[} / CR: | + ESC:{104:^[} / CR: | xline 1 | - ESC:{6:^[} / CR: | + ESC:{104:^[} / CR: | ^x | - {5:[No Name] [+] 5,1 Bot}| + {3:[No Name] [+] 5,1 Bot}| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]] screen:expect(expected_grid2) -- Undo. @@ -1489,10 +1471,10 @@ describe('TUI', function() screen:expect([[ foo | | - {4:~ }|*2 - {5:[No Name] [+] }| + {100:~ }|*2 + {3:[No Name] [+] }| :"^" | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- "bracketed paste" feed_data('\027[200~line 1\nline 2\n') @@ -1503,10 +1485,10 @@ describe('TUI', function() screen:expect([[ foo | | - {4:~ }|*2 - {5:[No Name] [+] }| + {100:~ }|*2 + {3:[No Name] [+] }| :"line 1^" | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- Dot-repeat/redo. feed_data('\027[27u') @@ -1515,10 +1497,10 @@ describe('TUI', function() screen:expect([[ foo |*2 ^ | - {4:~ }| - {5:[No Name] [+] }| + {100:~ }| + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -1562,20 +1544,20 @@ describe('TUI', function() screen:expect([[ foo | ^ | - {4:~ }|*2 - {5:[No Name] [+] }| + {100:~ }|*2 + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- Start pasting... feed_data('\027[200~line 1\nline 2\n') screen:expect([[ foo | ^ | - {4:~ }|*2 - {5:[No Name] [+] }| - {8:paste: Lua: [string ""]:4: fake fail} | - {3:-- TERMINAL --} | + {100:~ }|*2 + {3:[No Name] [+] }| + {101:paste: Lua: [string ""]:4: fake fail} | + {5:-- TERMINAL --} | ]]) -- Remaining chunks are discarded after vim.paste() failure. feed_data('line 3\nline 4\n') @@ -1591,20 +1573,20 @@ describe('TUI', function() screen:expect([[ foo |*2 ^ | - {4:~ }| - {5:[No Name] [+] }| + {100:~ }| + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- Editor should still work after failed/drained paste. feed_data('ityped input...\027[27u') screen:expect([[ foo |*2 typed input..^. | - {4:~ }| - {5:[No Name] [+] }| + {100:~ }| + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- Paste works if vim.paste() succeeds. child_exec_lua([[vim.paste = _G.save_paste_fn]]) @@ -1614,9 +1596,9 @@ describe('TUI', function() typed input...line A | line B | ^ | - {5:[No Name] [+] }| + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -1673,12 +1655,12 @@ describe('TUI', function() feed_data('\027[200~fail 1\nfail 2\n\027[201~') screen:expect([[ | - {4:~ }| - {5: }| - {8:paste: Lua: Vim:E21: Cannot make changes, 'modifia}| - {8:ble' is off} | - {10:Press ENTER or type command to continue}^ | - {3:-- TERMINAL --} | + {100:~ }| + {3: }| + {101:paste: Lua: Vim:E21: Cannot make changes, 'modifia}| + {101:ble' is off} | + {102:Press ENTER or type command to continue}^ | + {5:-- TERMINAL --} | ]]) feed_data('\n') -- to dismiss hit-enter prompt child_exec_lua('vim.bo.modifiable = true') @@ -1687,10 +1669,10 @@ describe('TUI', function() success 1 | success 2 | ^ | - {4:~ }| - {5:[No Name] [+] }| + {100:~ }| + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -1706,10 +1688,10 @@ describe('TUI', function() screen:expect([[ zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz| zzzzzzzzzzzzzz end^ | - {4:~ }|*2 - {5:[No Name] [+] }| - {3:-- INSERT --} | - {3:-- TERMINAL --} | + {100:~ }|*2 + {3:[No Name] [+] }| + {5:-- INSERT --} | + {5:-- TERMINAL --} | ]]) expect_child_buf_lines({ expected }) end) @@ -1722,10 +1704,10 @@ describe('TUI', function() feed_data('\027[200~' .. expected .. '\027[201~') screen:expect([[ | - {4:~ }|*3 - {5:[No Name] }| + {100:~ }|*3 + {3:[No Name] }| :<^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -1746,9 +1728,9 @@ describe('TUI', function() item 2998 | item 2999 | item 3000 end^ | - {5:[No Name] [+] 3000,14 Bot}| - {3:-- INSERT --} | - {3:-- TERMINAL --} | + {3:[No Name] [+] 3000,14 Bot}| + {5:-- INSERT --} | + {5:-- TERMINAL --} | ]]) feed_data('\027[27u') -- ESC: go to Normal mode. wait_for_mode('n') @@ -1759,9 +1741,9 @@ describe('TUI', function() item 2998 | item 2999 | item 3000 en^dd | - {5:[No Name] [+] 5999,13 Bot}| + {3:[No Name] [+] 5999,13 Bot}| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -1781,11 +1763,11 @@ describe('TUI', function() screen:expect([[ | pasted from terminal (1) | - {6:^[}[200~ | + {104:^[}[200~ | ^ | - {5:[No Name] [+] }| - {3:-- INSERT --} | - {3:-- TERMINAL --} | + {3:[No Name] [+] }| + {5:-- INSERT --} | + {5:-- TERMINAL --} | ]]) end) @@ -1798,10 +1780,10 @@ describe('TUI', function() feed_data('\027[201~') screen:expect([[ ^ | - {4:~ }|*3 - {5:[No Name] }| - {3:-- INSERT --} | - {3:-- TERMINAL --} | + {100:~ }|*3 + {3:[No Name] }| + {5:-- INSERT --} | + {5:-- TERMINAL --} | ]]) end) @@ -1813,10 +1795,10 @@ describe('TUI', function() feed_data('00~pasted from terminal\027[201~') screen:expect([[ pasted from terminal^ | - {4:~ }|*3 - {5:[No Name] [+] }| - {3:-- INSERT --} | - {3:-- TERMINAL --} | + {100:~ }|*3 + {3:[No Name] [+] }| + {5:-- INSERT --} | + {5:-- TERMINAL --} | ]]) end) @@ -1828,10 +1810,10 @@ describe('TUI', function() feed_data('1~') screen:expect([[ pasted from terminal^ | - {4:~ }|*3 - {5:[No Name] [+] }| - {3:-- INSERT --} | - {3:-- TERMINAL --} | + {100:~ }|*3 + {3:[No Name] [+] }| + {5:-- INSERT --} | + {5:-- TERMINAL --} | ]]) end) @@ -1850,18 +1832,18 @@ describe('TUI', function() feed_data('\027[200~pasted') -- phase 1 screen:expect([[ pasted^ | - {4:~ }|*3 - {5:[No Name] [+] }| - {3:-- INSERT --} | - {3:-- TERMINAL --} | + {100:~ }|*3 + {3:[No Name] [+] }| + {5:-- INSERT --} | + {5:-- TERMINAL --} | ]]) feed_data(' from terminal') -- phase 2 screen:expect([[ pasted from terminal^ | - {4:~ }|*3 - {5:[No Name] [+] }| - {3:-- INSERT --} | - {3:-- TERMINAL --} | + {100:~ }|*3 + {3:[No Name] [+] }| + {5:-- INSERT --} | + {5:-- TERMINAL --} | ]]) -- Send isolated "stop paste" sequence. feed_data('\027[201~') -- phase 3 @@ -1874,48 +1856,35 @@ describe('TUI', function() it('allows termguicolors to be set at runtime', function() screen:set_option('rgb', true) - screen:set_default_attr_ids({ - [1] = { reverse = true }, - [2] = { foreground = tonumber('0x4040ff'), fg_indexed = true }, - [3] = { bold = true, reverse = true }, - [4] = { bold = true }, - [5] = { reverse = true, foreground = tonumber('0xe0e000'), fg_indexed = true }, - [6] = { foreground = tonumber('0xe0e000'), fg_indexed = true }, - [7] = { reverse = true, foreground = Screen.colors.SeaGreen4 }, - [8] = { foreground = Screen.colors.SeaGreen4 }, - [9] = { bold = true, foreground = Screen.colors.Blue1 }, - [10] = { foreground = Screen.colors.Blue }, - }) - feed_data(':hi SpecialKey ctermfg=3 guifg=SeaGreen\n') feed_data('i') feed_data('\022\007') -- ctrl+g feed_data('\028\014') -- crtl+\ ctrl+N feed_data(':set termguicolors?\n') screen:expect([[ - {6:^^G} | - {2:~ }|*3 + {110:^^G} | + {111:~ }|*3 {3:[No Name] [+] }| notermguicolors | - {4:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed_data(':set termguicolors\n') screen:expect([[ - {8:^^G} | - {9:~}{10: }|*3 + {113:^^G} | + {1:~}{18: }|*3 {3:[No Name] [+] }| :set termguicolors | - {4:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed_data(':set notermguicolors\n') screen:expect([[ - {6:^^G} | - {2:~ }|*3 + {110:^^G} | + {111:~ }|*3 {3:[No Name] [+] }| :set notermguicolors | - {4:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -1957,68 +1926,54 @@ describe('TUI', function() child_exec_lua('vim.o.statusline="^^^^^^^"') child_exec_lua('vim.o.termguicolors=true') child_exec_lua('vim.cmd.terminal(...)', testprg('tty-test')) - screen:expect { - grid = [[ + screen:expect([[ ^tty ready | |*3 {2:^^^^^^^ }| | {3:-- TERMINAL --} | - ]], - } + ]]) feed_data( ':call chansend(&channel, "\\033[38;5;3mtext\\033[38:2:255:128:0mcolor\\033[0;10mtext")\n' ) - screen:expect { - grid = [[ + screen:expect([[ ^tty ready | {4:text}{5:color}text | |*2 {2:^^^^^^^ }| | {3:-- TERMINAL --} | - ]], - } + ]]) feed_data(':set notermguicolors\n') - screen:expect { - grid = [[ + screen:expect([[ ^tty ready | {4:text}colortext | |*2 {6:^^^^^^^}{7: }| :set notermguicolors | {3:-- TERMINAL --} | - ]], - } + ]]) end) -- Note: libvterm doesn't support colored underline or undercurl. it('supports undercurl and underdouble when run in :terminal', function() - screen:set_default_attr_ids({ - [1] = { reverse = true }, - [2] = { bold = true, reverse = true }, - [3] = { bold = true }, - [4] = { foreground = 12 }, - [5] = { undercurl = true }, - [6] = { underdouble = true }, - }) child_session:request('nvim_set_hl', 0, 'Visual', { undercurl = true }) feed_data('ifoobar\027V') screen:expect([[ - {5:fooba}^r | - {4:~ }|*3 - {2:[No Name] [+] }| - {3:-- VISUAL LINE --} | - {3:-- TERMINAL --} | + {114:fooba}^r | + {100:~ }|*3 + {3:[No Name] [+] }| + {5:-- VISUAL LINE --} | + {5:-- TERMINAL --} | ]]) child_session:request('nvim_set_hl', 0, 'Visual', { underdouble = true }) screen:expect([[ - {6:fooba}^r | - {4:~ }|*3 - {2:[No Name] [+] }| - {3:-- VISUAL LINE --} | - {3:-- TERMINAL --} | + {115:fooba}^r | + {100:~ }|*3 + {3:[No Name] [+] }| + {5:-- VISUAL LINE --} | + {5:-- TERMINAL --} | ]]) end) @@ -2102,24 +2057,24 @@ describe('TUI', function() child_session:request('nvim_set_option_value', 'listchars', 'eol:$', { win = 0 }) feed_data('gg') local singlewidth_screen = [[ - {12:^℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃}| - {12:℃℃℃℃℃℃℃℃℃℃}{15:$}{12: }| + {107:^℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃}| + {107:℃℃℃℃℃℃℃℃℃℃}{116:$}{107: }| ℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃| - ℃℃℃℃℃℃℃℃℃℃{4:$} | - {5:[No Name] [+] }| + ℃℃℃℃℃℃℃℃℃℃{100:$} | + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]] -- When grid assumes "℃" to be double-width but host terminal assumes it to be single-width, -- the second cell of "℃" is a space and the attributes of the "℃" are applied to it. local doublewidth_screen = [[ - {12:^℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ }| - {12:℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ }| - {12:℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ }{15:$}{12: }| - ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ {4:@@@@}| - {5:[No Name] [+] }| + {107:^℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ }| + {107:℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ }| + {107:℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ }{116:$}{107: }| + ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ ℃ {100:@@@@}| + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]] screen:expect(singlewidth_screen) child_session:request('nvim_set_option_value', 'ambiwidth', 'double', {}) @@ -2146,24 +2101,24 @@ describe('TUI', function() child_session:request('nvim_set_option_value', 'listchars', 'eol:$', { win = 0 }) feed_data('gg') local singlewidth_screen = [[ - {12:^✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓}| - {12:✓✓✓✓✓✓✓✓✓✓}{15:$}{12: }| + {107:^✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓}| + {107:✓✓✓✓✓✓✓✓✓✓}{116:$}{107: }| ✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓| - ✓✓✓✓✓✓✓✓✓✓{4:$} | - {5:[No Name] [+] }| + ✓✓✓✓✓✓✓✓✓✓{100:$} | + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]] -- When grid assumes "✓" to be double-width but host terminal assumes it to be single-width, -- the second cell of "✓" is a space and the attributes of the "✓" are applied to it. local doublewidth_screen = [[ - {12:^✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ }| - {12:✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ }| - {12:✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ }{15:$}{12: }| - ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ {4:@@@@}| - {5:[No Name] [+] }| + {107:^✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ }| + {107:✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ }| + {107:✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ }{116:$}{107: }| + ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ {100:@@@@}| + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]] screen:expect(singlewidth_screen) child_session:request('nvim_set_option_value', 'ambiwidth', 'double', {}) @@ -2195,14 +2150,14 @@ describe('TUI', function() -- Close the :intro message and redraw the lines. feed_data('\n') screen:expect([[ - {12:^ꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨ}| - {12:ꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨ}|*310 - {12:ꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨ℃ }| + {107:^ꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨ}| + {107:ꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨ}|*310 + {107:ꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨ℃ }| b | - {4:~ }|*17 - {5:[No Name] [+] }| + {100:~ }|*17 + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -2239,7 +2194,7 @@ describe('TUI', function() screen:expect([[ ^ꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨ| ꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨꝨ|*325 - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) retry(nil, nil, function() eq('[No Name] + - Nvim', api.nvim_buf_get_var(0, 'term_title')) @@ -2248,29 +2203,25 @@ describe('TUI', function() it('visual bell (padding) does not crash #21610', function() feed_data ':set visualbell\n' - screen:expect { - grid = [[ + screen:expect([[ ^ | - {4:~ }|*3 - {5:[No Name] }| + {100:~ }|*3 + {3:[No Name] }| :set visualbell | - {3:-- TERMINAL --} | - ]], - } + {5:-- TERMINAL --} | + ]]) -- move left is enough to invoke the bell feed_data 'h' -- visual change to show we process events after this feed_data 'i' - screen:expect { - grid = [[ + screen:expect([[ ^ | - {4:~ }|*3 - {5:[No Name] }| - {3:-- INSERT --} | - {3:-- TERMINAL --} | - ]], - } + {100:~ }|*3 + {3:[No Name] }| + {5:-- INSERT --} | + {5:-- TERMINAL --} | + ]]) end) it('no assert failure on deadly signal #21896', function() @@ -2280,7 +2231,7 @@ describe('TUI', function() | [Process exited 1]^ | |*3 - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -2303,25 +2254,18 @@ describe('TUI', function() ]], {} ) - screen:set_default_attr_ids({ - [1] = { reverse = true }, - [2] = { bold = true, foreground = Screen.colors.Blue }, - [3] = { foreground = Screen.colors.Blue }, - [4] = { reverse = true, bold = true }, - [5] = { bold = true }, - }) screen:expect([[ ^ | - {2:~}{3: }|*3 - {4:[No Name] }| + {1:~}{18: }|*3 + {3:[No Name] }| | {5:-- TERMINAL --} | ]]) feed_data('i') screen:expect([[ ^ | - {2:~}{3: }|*3 - {4:[No Name] }| + {1:~}{18: }|*3 + {3:[No Name] }| {5:-- INSERT --} | {5:-- TERMINAL --} | ]]) @@ -2331,18 +2275,18 @@ describe('TUI', function() child_session:request('nvim_echo', { { 'foo' } }, false, {}) screen:expect([[ ^ | - {4:~ }|*3 - {5:[No Name] }| + {100:~ }|*3 + {3:[No Name] }| foo | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) exec_lua([[vim.uv.kill(vim.fn.jobpid(vim.bo.channel), 'sigwinch')]]) screen:expect([[ ^ | - {4:~ }|*3 - {5:[No Name] }| + {100:~ }|*3 + {3:[No Name] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -2354,18 +2298,18 @@ describe('TUI', function() feed_data(':call jobwait([g:id])\n') screen:expect([[ | - {4:~ }|*3 - {5:[No Name] }| + {100:~ }|*3 + {3:[No Name] }| :call jobwait([g:id]) | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed_data('\003') screen:expect([[ ^ | - {4:~ }|*3 - {5:[No Name] }| + {100:~ }|*3 + {3:[No Name] }| Type :qa and press to exit Nvim | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -2373,29 +2317,29 @@ describe('TUI', function() feed_data('ifoo\027') feed_data('/foo') screen:expect([[ - {1:foo} | - {4:~ }|*3 - {5:[No Name] [+] }| + {2:foo} | + {100:~ }|*3 + {3:[No Name] [+] }| /foo^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) screen:sleep(10) feed_data('b') screen:expect([[ foo | - {4:~ }|*3 - {5:[No Name] [+] }| + {100:~ }|*3 + {3:[No Name] [+] }| /foob^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) screen:sleep(10) feed_data('a') screen:expect([[ foo | - {4:~ }|*3 - {5:[No Name] [+] }| + {100:~ }|*3 + {3:[No Name] [+] }| /fooba^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -2462,13 +2406,9 @@ describe('TUI', function() it('resize at startup #17285 #15044 #11330', function() local screen = Screen.new(50, 10) - screen:set_default_attr_ids({ - [1] = { reverse = true }, - [2] = { bold = true, foreground = Screen.colors.Blue }, - [3] = { bold = true }, - [4] = { foreground = tonumber('0x4040ff'), fg_indexed = true }, - [5] = { bold = true, reverse = true }, - [6] = { foreground = Screen.colors.White, background = Screen.colors.DarkGreen }, + screen:add_extra_attr_ids({ + [100] = { foreground = tonumber('0x4040ff'), fg_indexed = true }, + [101] = { foreground = Screen.colors.Gray100, background = Screen.colors.DarkGreen }, }) fn.jobstart({ nvim_prog, @@ -2493,9 +2433,9 @@ describe('TUI', function() ]]) screen:expect([[ ^ │ | - {2:~ }│{4:~ }|*6 - {2:~ }│ | - {5:new }{6:{MATCH:<.*[/\]nvim} [-] }| + {1:~ }│{100:~ }|*6 + {1:~ }│ | + {3:new }{101:{MATCH:<.*[/\]nvim} [-] }| | ]]) end) @@ -2504,33 +2444,39 @@ describe('TUI', function() for _, guicolors in ipairs({ 'notermguicolors', 'termguicolors' }) do it('has no black flicker when clearing regions during startup with ' .. guicolors, function() local screen = Screen.new(50, 10) + screen:add_extra_attr_ids({ + [100] = { + foreground = Screen.colors.NvimLightGrey2, + background = Screen.colors.NvimDarkGrey2, + }, + }) fn.jobstart({ nvim_prog, '--clean', '--cmd', 'set ' .. guicolors, '--cmd', + 'echo "foo"', + '--cmd', 'sleep 10', }, { term = true, - env = { - VIMRUNTIME = os.getenv('VIMRUNTIME'), - }, }) - screen:expect({ - grid = [[ + if guicolors == 'termguicolors' then + screen:expect([[ + {100:^ }| + {100: }|*7 + {100:foo }| + | + ]]) + else + screen:expect([[ ^ | - |*9 - ]], - intermediate = true, - }) - screen:try_resize(51, 11) - screen:expect({ - grid = [[ - ^ | - |*10 - ]], - }) + |*7 + foo | + | + ]]) + end end) end @@ -2551,27 +2497,23 @@ describe('TUI', function() os.remove(script_file) end) local screen = tt.setup_child_nvim({ '--clean', '-l', script_file }) - screen:expect { - grid = [[ + screen:expect([[ ^ | ~ |*3 [No Name] 0,0-1 All| | - {3:-- TERMINAL --} | - ]], - } + {5:-- TERMINAL --} | + ]]) feed_data(':put =v:argv + [v:progname]\n') - screen:expect { - grid = [[ + screen:expect([[ Xargv0nvim | --embed | --clean | ^Xargv0nvim | [No Name] [+] 5,1 Bot| 4 more lines | - {3:-- TERMINAL --} | - ]], - } + {5:-- TERMINAL --} | + ]]) end) it("float is still highlighted with 'winblend' over uninitialized cells #34360", function() @@ -2589,11 +2531,11 @@ describe('TUI', function() end) local screen = tt.setup_child_nvim({ '--clean', '-u', 'Xblend.lua' }) screen:expect([[ - {3:^foo} | + {5:^foo} | ~ |*3 [No Name] [+] 1,1 All| - {3:foo} | - {3:-- TERMINAL --} | + {5:foo} | + {5:-- TERMINAL --} | ]]) end) @@ -2613,11 +2555,9 @@ describe('TUI', function() screen:expect([[ :w testF | :q | - abc | - | - [Process exited 0]^ | - | - {3:-- TERMINAL --} | + ^ | + |*3 + {5:-- TERMINAL --} | ]]) end) @@ -2631,23 +2571,21 @@ describe('TUI', function() '--cmd', ':nnoremap :echomsg "\\"', }) - screen:expect { - grid = [[ + screen:expect([[ ^ | - {4:~ }|*3 - {5:[No Name] }| + {100:~ }|*3 + {3:[No Name] }| | - {3:-- TERMINAL --} | - ]], - } + {5:-- TERMINAL --} | + ]]) command([[call chansend(b:terminal_job_id, "\")]]) screen:expect([[ ^ | - {4:~ }|*3 - {5:[No Name] }| + {100:~ }|*3 + {3:[No Name] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -2661,28 +2599,24 @@ describe('TUI', function() '--cmd', 'call setline(1, ["1st line" .. repeat(" ", 153), "2nd line"])', }, { cols = 80 }) - screen:expect { - grid = [[ + screen:expect([[ ^1st line | |*2 2nd line | - {5:[No Name] [+] 1,1 All}| + {3:[No Name] [+] 1,1 All}| | - {3:-- TERMINAL --} | - ]], - } + {5:-- TERMINAL --} | + ]]) feed_data('$') - screen:expect { - grid = [[ + screen:expect([[ 1st line | | ^ | 2nd line | - {5:[No Name] [+] 1,161 All}| + {3:[No Name] [+] 1,161 All}| | - {3:-- TERMINAL --} | - ]], - } + {5:-- TERMINAL --} | + ]]) end) it('draws screen lines with leading spaces correctly #29711', function() @@ -2691,17 +2625,14 @@ describe('TUI', function() '--cmd', 'set foldcolumn=6 | call setline(1, ["", repeat("aabb", 1000)]) | echo 42', }, { extra_rows = 10, cols = 66 }) - screen:expect { - grid = [[ + screen:expect([[ ^ | aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabb|*12 aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabba@@@| [No Name] [+] 1,0-1 Top| 42 | - -- TERMINAL -- | - ]], - attr_ids = {}, - } + {5:-- TERMINAL --} | + ]]) feed_data('\12') -- Ctrl-L -- The first line counts as 3 cells. -- For the second line, 6 repeated spaces at the start counts as 2 cells, @@ -2710,17 +2641,14 @@ describe('TUI', function() -- 3 + 8 * 62 = 499 cells have been counted. -- The 6 repeated spaces at the start of the next screen line exceeds the -- 500-cell limit, so the buffer is flushed after these spaces. - screen:expect { - grid = [[ + screen:expect([[ ^ | aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabb|*12 aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabba@@@| [No Name] [+] 1,0-1 Top| | - -- TERMINAL -- | - ]], - attr_ids = {}, - } + {5:-- TERMINAL --} | + ]]) end) it('no heap-buffer-overflow when changing &columns', function() @@ -2734,28 +2662,22 @@ describe('TUI', function() 'call setline(1, ["a"->repeat(&columns)])', }, { env = { TERM = 'ansi' } }) - screen:expect { - grid = [[ - ^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| - ~ |*3 - [No Name] [+] 1,1 All| - | - -- TERMINAL -- | - ]], - attr_ids = {}, - } + screen:expect([[ + {117:^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| + {117:~ }|*3 + {118:[No Name] [+] 1,1 All}| + {117: }| + {5:-- TERMINAL --} | + ]]) feed_data(':set columns=12\n') - screen:expect { - grid = [[ - ^aaaaaaaaaaaa | - aaaaaaaaaaaa |*3 - < All | - | - -- TERMINAL -- | - ]], - attr_ids = {}, - } + screen:expect([[ + {117:^aaaaaaaaaaaa }| + {117:aaaaaaaaaaaa }|*3 + {118:< All}{117: }| + {117: }| + {5:-- TERMINAL --} | + ]]) -- Wider than TUI, so screen state will look weird. -- Wait for the statusline to redraw to confirm that the TUI lives and ASAN is happy. @@ -2782,25 +2704,21 @@ describe('TUI UIEnter/UILeave', function() '--cmd', 'autocmd VimEnter * :call add(g:evs, "VimEnter")', }) - screen:expect { - grid = [[ + screen:expect([[ ^ | - {4:~ }|*3 - {5:[No Name] }| + {100:~ }|*3 + {3:[No Name] }| | - {3:-- TERMINAL --} | - ]], - } + {5:-- TERMINAL --} | + ]]) feed_data(':echo g:evs\n') - screen:expect { - grid = [[ + screen:expect([[ ^ | - {4:~ }|*3 - {5:[No Name] }| + {100:~ }|*3 + {3:[No Name] }| ['VimEnter', 'UIEnter'] | - {3:-- TERMINAL --} | - ]], - } + {5:-- TERMINAL --} | + ]]) end) end) @@ -2826,10 +2744,10 @@ describe('TUI FocusGained/FocusLost', function() screen:expect([[ ^ | - {4:~ }|*3 - {5:[No Name] }| + {100:~ }|*3 + {3:[No Name] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) child_session = n.connect(child_server) child_session:request( @@ -2848,19 +2766,19 @@ describe('TUI FocusGained/FocusLost', function() feed_data('\027[I') screen:expect([[ ^ | - {4:~ }|*3 - {5:[No Name] }| + {100:~ }|*3 + {3:[No Name] }| gained | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed_data('\027[O') screen:expect([[ ^ | - {4:~ }|*3 - {5:[No Name] }| + {100:~ }|*3 + {3:[No Name] }| lost | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) end) @@ -2868,31 +2786,29 @@ describe('TUI FocusGained/FocusLost', function() it('in insert-mode', function() feed_data(':set noshowmode\r') feed_data('i') - screen:expect { - grid = [[ + screen:expect([[ ^ | - {4:~ }|*3 - {5:[No Name] }| + {100:~ }|*3 + {3:[No Name] }| :set noshowmode | - {3:-- TERMINAL --} | - ]], - } + {5:-- TERMINAL --} | + ]]) retry(2, 3 * screen.timeout, function() feed_data('\027[I') screen:expect([[ ^ | - {4:~ }|*3 - {5:[No Name] }| + {100:~ }|*3 + {3:[No Name] }| gained | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed_data('\027[O') screen:expect([[ ^ | - {4:~ }|*3 - {5:[No Name] }| + {100:~ }|*3 + {3:[No Name] }| lost | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) end) @@ -2904,22 +2820,13 @@ describe('TUI FocusGained/FocusLost', function() feed_data('\027[I') screen:expect([[ | - {4:~ }|*3 - {5:[No Name] }| + {100:~ }|*3 + {3:[No Name] }| :^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed_data('\027[O') - screen:expect { - grid = [[ - | - {4:~ }|*3 - {5:[No Name] }| - :^ | - {3:-- TERMINAL --} | - ]], - unchanged = true, - } + screen:expect_unchanged() end) it('in cmdline-mode', function() @@ -2956,16 +2863,14 @@ describe('TUI FocusGained/FocusLost', function() feed_data(':terminal zia\n') -- Wait for terminal to be ready. - screen:expect { - grid = [[ + screen:expect([[ ^ready $ zia | | [Process exited 0] | |*2 :terminal zia | - {3:-- TERMINAL --} | - ]], - } + {5:-- TERMINAL --} | + ]]) feed_data('\027[I') screen:expect { @@ -2975,7 +2880,7 @@ describe('TUI FocusGained/FocusLost', function() [Process exited 0] | |*2 gained | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]], timeout = (4 * screen.timeout), } @@ -2987,7 +2892,7 @@ describe('TUI FocusGained/FocusLost', function() [Process exited 0] | |*2 lost | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -2995,31 +2900,18 @@ describe('TUI FocusGained/FocusLost', function() feed_data(":echom 'msg1'|echom 'msg2'|echom 'msg3'|echom 'msg4'|echom 'msg5'\n") -- Execute :messages to provoke the press-enter prompt. feed_data(':messages\n') - screen:expect { - grid = [[ + screen:expect([[ msg1 | msg2 | msg3 | msg4 | msg5 | - {10:Press ENTER or type command to continue}^ | - {3:-- TERMINAL --} | - ]], - } + {102:Press ENTER or type command to continue}^ | + {5:-- TERMINAL --} | + ]]) feed_data('\027[I') feed_data('\027[I') - screen:expect { - grid = [[ - msg1 | - msg2 | - msg3 | - msg4 | - msg5 | - {10:Press ENTER or type command to continue}^ | - {3:-- TERMINAL --} | - ]], - unchanged = true, - } + screen:expect_unchanged() end) end) @@ -3046,11 +2938,11 @@ describe("TUI 't_Co' (terminal colors)", function() local tline if maxcolors == 8 then - tline = '{9:~ }' + tline = '{112:~ }' elseif maxcolors == 16 then tline = '~ ' else - tline = '{4:~ }' + tline = '{100:~ }' end screen:expect(string.format( @@ -3058,7 +2950,7 @@ describe("TUI 't_Co' (terminal colors)", function() ^ | %s|*4 | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]], tline )) @@ -3069,7 +2961,7 @@ describe("TUI 't_Co' (terminal colors)", function() ^ | %s|*4 %-3s | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]], tline, tostring(maxcolors and maxcolors or '') @@ -3388,9 +3280,9 @@ describe('TUI', function() feed_data('Gitext') screen:expect([[ text^ | - {4:~ }|*4 - {3:-- INSERT --} | - {3:-- TERMINAL --} | + {100:~ }|*4 + {5:-- INSERT --} | + {5:-- TERMINAL --} | ]]) retry(nil, 3000, function() -- Wait for log file to be flushed. @@ -3405,22 +3297,14 @@ describe('TUI', function() screen:expect([[ ^ | - {4:~ }|*4 + {100:~ }|*4 | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) feed_data(string.format('\027]52;c;%s\027\\', string.rep('A', 8192))) - screen:expect { - grid = [[ - ^ | - {4:~ }|*4 - | - {3:-- TERMINAL --} | - ]], - unchanged = true, - } + screen:expect_unchanged() end) it('queries the terminal for truecolor support', function() @@ -3694,10 +3578,10 @@ describe('TUI bg color', function() }) screen:expect([[ ^ | - {3:~} |*3 - {5:[No Name] 0,0-1 All}| + {5:~} |*3 + {3:[No Name] 0,0-1 All}| did OptionSet, yay! | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -3749,18 +3633,18 @@ describe('TUI client', function() feed_data('iHello, World') screen_server:expect([[ Hello, World^ | - {4:~ }|*3 - {5:[No Name] [+] }| - {3:-- INSERT --} | - {3:-- TERMINAL --} | + {100:~ }|*3 + {3:[No Name] [+] }| + {5:-- INSERT --} | + {5:-- TERMINAL --} | ]]) feed_data('\027') local s0 = [[ Hello, Worl^d | - {4:~ }|*3 - {5:[No Name] [+] }| + {100:~ }|*3 + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]] screen_server:expect(s0) @@ -3775,7 +3659,7 @@ describe('TUI client', function() }) screen_client:expect(s0) - -- XXX: should has("gui_running") be 1 when there is a remote TUI? + -- 3: should has("gui_running") be 1 when there is a remote TUI? feed_data(':echo "GUI Running: " .. has("gui_running")\013') screen_client:expect({ any = 'GUI Running: 1' }) @@ -3784,9 +3668,9 @@ describe('TUI client', function() feed_data('0:set lines=3\n') local s1 = [[ ^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| - {5:[No Name] [+] }| + {3:[No Name] [+] }| |*4 - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]] screen_client:expect(s1) screen_server:expect(s1) @@ -3796,10 +3680,10 @@ describe('TUI client', function() feed_data(':restart!\n') screen_client:expect([[ ^ | - {4:~ }|*3 - {5:[No Name] }| + {100:~ }|*3 + {3:[No Name] }| | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) screen_server:expect({ any = vim.pesc('[Process exited 0]') }) @@ -3830,9 +3714,9 @@ describe('TUI client', function() screen_client:expect([[ Halloj^! | - {4:~ }|*4 + {100:~ }|*4 | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) -- No heap-use-after-free when receiving UI events after deadly signal #22184 @@ -3843,7 +3727,7 @@ describe('TUI client', function() | [Process exited 1]^ | |*3 - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) eq(0, api.nvim_get_vvar('shell_error')) @@ -3856,15 +3740,15 @@ describe('TUI client', function() fn.jobstart({ nvim_prog, '--remote-ui', '--server', server_pipe }, { term = true }) command('startinsert') screen_client:expect([[ - {4:<<<}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {100:<<<}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|*3 aaaaaa^ | - {3:-- INSERT --} | - {3:-- TERMINAL --} | + {5:-- INSERT --} | + {5:-- TERMINAL --} | ]]) feed_data('\027') - -- XXX: should has("gui_running") be 1 when there is a remote TUI? + -- 3: should has("gui_running") be 1 when there is a remote TUI? feed_data(':echo "GUI Running: " .. has("gui_running")\013') screen_client:expect({ any = 'GUI Running: 1' }) @@ -3873,9 +3757,9 @@ describe('TUI client', function() feed_data(':restart!\n') screen_client:expect([[ ^ | - {4:~ }|*4 + {100:~ }|*4 | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) retry(nil, nil, function() eq(nil, vim.uv.fs_stat(server_pipe)) @@ -3904,7 +3788,7 @@ describe('TUI client', function() | [Process exited 1]^ | |*3 - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -3926,36 +3810,30 @@ describe('TUI client', function() '--cmd', nvim_set .. ' notermguicolors laststatus=2 background=dark', }) - screen_server:expect { - grid = [[ + screen_server:expect([[ ^ | - {4:~ }|*3 - {5:[No Name] }| + {100:~ }|*3 + {3:[No Name] }| | - {3:-- TERMINAL --} | - ]], - } + {5:-- TERMINAL --} | + ]]) feed_data('iHello, World') - screen_server:expect { - grid = [[ + screen_server:expect([[ Hello, World^ | - {4:~ }|*3 - {5:[No Name] [+] }| - {3:-- INSERT --} | - {3:-- TERMINAL --} | - ]], - } + {100:~ }|*3 + {3:[No Name] [+] }| + {5:-- INSERT --} | + {5:-- TERMINAL --} | + ]]) feed_data('\027') - screen_server:expect { - grid = [[ + screen_server:expect([[ Hello, Worl^d | - {4:~ }|*3 - {5:[No Name] [+] }| + {100:~ }|*3 + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | - ]], - } + {5:-- TERMINAL --} | + ]]) set_session(client_super) local screen_client = tt.setup_child_nvim({ @@ -3964,15 +3842,13 @@ describe('TUI client', function() server_pipe, }) - screen_client:expect { - grid = [[ + screen_client:expect([[ Hello, Worl^d | - {4:~ }|*3 - {5:[No Name] [+] }| + {100:~ }|*3 + {3:[No Name] [+] }| | - {3:-- TERMINAL --} | - ]], - } + {5:-- TERMINAL --} | + ]]) -- quitting the server set_session(server_super) diff --git a/test/functional/terminal/window_spec.lua b/test/functional/terminal/window_spec.lua index a65d18de70..e81456c6b2 100644 --- a/test/functional/terminal/window_spec.lua +++ b/test/functional/terminal/window_spec.lua @@ -60,46 +60,46 @@ describe(':terminal window', function() feed([[]]) feed([[:set numberwidth=1 numberi]]) screen:expect([[ - {7:1 }tty ready | - {7:2 }rows: 6, cols: 48 | - {7:3 }^ | - {7:4 } | - {7:5 } | - {7:6 } | - {3:-- TERMINAL --} | + {121:1 }tty ready | + {121:2 }rows: 6, cols: 48 | + {121:3 }^ | + {121:4 } | + {121:5 } | + {121:6 } | + {5:-- TERMINAL --} | ]]) feed_data('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') screen:expect([[ - {7:1 }tty ready | - {7:2 }rows: 6, cols: 48 | - {7:3 }abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUV| - {7:4 }WXYZ^ | - {7:5 } | - {7:6 } | - {3:-- TERMINAL --} | + {121:1 }tty ready | + {121:2 }rows: 6, cols: 48 | + {121:3 }abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUV| + {121:4 }WXYZ^ | + {121:5 } | + {121:6 } | + {5:-- TERMINAL --} | ]]) -- numberwidth=9 feed([[]]) feed([[:set numberwidth=9 numberi]]) screen:expect([[ - {7: 1 }tty ready | - {7: 2 }rows: 6, cols: 48 | - {7: 3 }abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNO| - {7: 4 }PQRSTUVWXYZrows: 6, cols: 41 | - {7: 5 }^ | - {7: 6 } | - {3:-- TERMINAL --} | + {121: 1 }tty ready | + {121: 2 }rows: 6, cols: 48 | + {121: 3 }abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNO| + {121: 4 }PQRSTUVWXYZrows: 6, cols: 41 | + {121: 5 }^ | + {121: 6 } | + {5:-- TERMINAL --} | ]]) feed_data(' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') screen:expect([[ - {7: 1 }tty ready | - {7: 2 }rows: 6, cols: 48 | - {7: 3 }abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNO| - {7: 4 }PQRSTUVWXYZrows: 6, cols: 41 | - {7: 5 } abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN| - {7: 6 }OPQRSTUVWXYZ^ | - {3:-- TERMINAL --} | + {121: 1 }tty ready | + {121: 2 }rows: 6, cols: 48 | + {121: 3 }abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNO| + {121: 4 }PQRSTUVWXYZrows: 6, cols: 41 | + {121: 5 } abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN| + {121: 6 }OPQRSTUVWXYZ^ | + {5:-- TERMINAL --} | ]]) end) end) @@ -108,33 +108,33 @@ describe(':terminal window', function() it('wraps text', function() command([[set number statuscolumn=++%l\ \ ]]) screen:expect([[ - {7:++1 }tty ready | - {7:++2 }rows: 6, cols: 45 | - {7:++3 }^ | - {7:++4 } | - {7:++5 } | - {7:++6 } | - {3:-- TERMINAL --} | + {121:++1 }tty ready | + {121:++2 }rows: 6, cols: 45 | + {121:++3 }^ | + {121:++4 } | + {121:++5 } | + {121:++6 } | + {5:-- TERMINAL --} | ]]) feed_data('\n\n\n\n\nabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') screen:expect([[ - {7:++4 } | - {7:++5 } | - {7:++6 } | - {7:++7 } | - {7:++8 }abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRS| - {7:++9 }TUVWXYZ^ | - {3:-- TERMINAL --} | + {121:++4 } | + {121:++5 } | + {121:++6 } | + {121:++7 } | + {121:++8 }abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRS| + {121:++9 }TUVWXYZ^ | + {5:-- TERMINAL --} | ]]) feed_data('\nabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') screen:expect([[ - {7:++ 7 } | - {7:++ 8 }abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQR| - {7:++ 9 }STUVWXYZ | - {7:++10 }abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQR| - {7:++11 }STUVWXYZrows: 6, cols: 44 | - {7:++12 }^ | - {3:-- TERMINAL --} | + {121:++ 7 } | + {121:++ 8 }abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQR| + {121:++ 9 }STUVWXYZ | + {121:++10 }abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQR| + {121:++11 }STUVWXYZrows: 6, cols: 44 | + {121:++12 }^ | + {5:-- TERMINAL --} | ]]) end) end) @@ -155,7 +155,7 @@ describe(':terminal window', function() tty ready | ^ | |*4 - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) end) @@ -171,7 +171,7 @@ describe(':terminal window', function() line3 | line4 | ^ | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -209,7 +209,7 @@ describe(':terminal with multigrid', function() ^ | |*4 ## grid 3 - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) screen:try_resize_grid(2, 20, 10) @@ -226,7 +226,7 @@ describe(':terminal with multigrid', function() ^ | |*7 ## grid 3 - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end @@ -243,7 +243,7 @@ describe(':terminal with multigrid', function() rows: 3, cols: 70 | ^ | ## grid 3 - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end @@ -263,7 +263,7 @@ describe(':terminal with multigrid', function() ^ | | ## grid 3 - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end end) diff --git a/test/functional/testterm.lua b/test/functional/testterm.lua index 17209d947e..656e97e6be 100644 --- a/test/functional/testterm.lua +++ b/test/functional/testterm.lua @@ -119,25 +119,31 @@ function M.setup_screen(extra_rows, cmd, cols, env, screen_opts) api.nvim_command('highlight StatusLineTermNC ctermbg=2 ctermfg=8') local screen = Screen.new(cols, 7 + extra_rows, screen_opts or { rgb = false }) - screen:set_default_attr_ids({ - [1] = { reverse = true }, -- focused cursor - [2] = { background = 11 }, -- unfocused cursor - [3] = { bold = true }, - [4] = { foreground = 12 }, -- NonText in :terminal session - [5] = { bold = true, reverse = true }, - [6] = { foreground = 81 }, -- SpecialKey in :terminal session - [7] = { foreground = 130 }, -- LineNr in host session - [8] = { foreground = 15, background = 1 }, -- ErrorMsg in :terminal session - [9] = { foreground = 4 }, - [10] = { foreground = 121 }, -- MoreMsg in :terminal session - [11] = { foreground = 11 }, -- LineNr in :terminal session - [12] = { underline = true }, - [13] = { underline = true, reverse = true }, - [14] = { underline = true, reverse = true, bold = true }, - [15] = { underline = true, foreground = 12 }, - [16] = { background = 248, foreground = 0 }, -- Visual in :terminal session - [17] = { background = 2, foreground = 0 }, -- StatusLineTerm - [18] = { background = 2, foreground = 8 }, -- StatusLineTermNC + screen:add_extra_attr_ids({ + [100] = { foreground = 12 }, + [101] = { foreground = 15, background = 1 }, + [102] = { foreground = 121 }, + [103] = { foreground = 11 }, + [104] = { foreground = 81 }, + [105] = { underline = true, reverse = true }, + [106] = { underline = true, reverse = true, bold = true }, + [107] = { underline = true }, + [108] = { background = 248, foreground = Screen.colors.Black }, + [109] = { bold = true, background = 121, foreground = Screen.colors.Grey0 }, + [110] = { fg_indexed = true, foreground = tonumber('0xe0e000') }, + [111] = { fg_indexed = true, foreground = tonumber('0x4040ff') }, + [112] = { foreground = 4 }, + [113] = { foreground = Screen.colors.SeaGreen4 }, + [114] = { undercurl = true }, + [115] = { underdouble = true }, + [116] = { underline = true, foreground = 12 }, + [117] = { background = 1 }, + [118] = { background = 1, reverse = true }, + [119] = { background = 2, foreground = 8 }, + [120] = { foreground = Screen.colors.Black, background = 2 }, + [121] = { foreground = 130 }, + [122] = { background = 46 }, + [123] = { foreground = 2 }, }) api.nvim_command('enew') @@ -170,7 +176,7 @@ function M.setup_screen(extra_rows, cmd, cols, env, screen_opts) table.insert(expected, empty_line) end - table.insert(expected, '{3:-- TERMINAL --}' .. ((' '):rep(cols - 14))) + table.insert(expected, '{5:-- TERMINAL --}' .. ((' '):rep(cols - 14))) screen:expect(table.concat(expected, '|\n') .. '|') else -- This eval also acts as a poke_eventloop(). diff --git a/test/functional/ui/output_spec.lua b/test/functional/ui/output_spec.lua index 0554166f27..da4c28be7f 100644 --- a/test/functional/ui/output_spec.lua +++ b/test/functional/ui/output_spec.lua @@ -35,9 +35,9 @@ describe('shell command :!', function() }) screen:expect([[ ^ | - {4:~ }|*4 + {100:~ }|*4 | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -52,11 +52,11 @@ describe('shell command :!', function() tt.feed_data(':!printf foo; sleep 200\n') screen:expect([[ | - {4:~ }|*2 - {5: }| + {100:~ }|*2 + {3: }| :!printf foo; sleep 200 | foo | - {3:-- TERMINAL --} | + {5:-- TERMINAL --} | ]]) end) @@ -71,23 +71,15 @@ describe('shell command :!', function() -- Final chunk of output should always be displayed, never skipped. -- (Throttling is non-deterministic, this test is merely a sanity check.) - screen:expect( - [[ + screen:expect([[ 29997: foo | 29998: foo | 29999: foo | 30000: foo | | - {10:Press ENTER or type command to continue}^ | - {3:-- TERMINAL --} | - ]], - { - -- test/functional/testnvim.lua defaults to background=light. - [1] = { reverse = true }, - [3] = { bold = true }, - [10] = { foreground = 2 }, - } - ) + {123:Press ENTER or type command to continue}^ | + {5:-- TERMINAL --} | + ]]) end) end) @@ -111,14 +103,12 @@ describe('shell command :!', function() local screen = Screen.new(50, 4) -- Print TAB chars. #2958 feed([[:!printf '1\t2\t3']]) - screen:expect { - grid = [[ + screen:expect([[ {3: }| :!printf '1\t2\t3' | 1 2 3 | {6:Press ENTER or type command to continue}^ | - ]], - } + ]]) feed([[]]) -- Print BELL control code. #4338 @@ -126,11 +116,11 @@ describe('shell command :!', function() feed([[:!printf '\007\007\007\007text']]) screen:expect { grid = [[ - {3: }| - :!printf '\007\007\007\007text' | - text | - {6:Press ENTER or type command to continue}^ | - ]], + {3: }| + :!printf '\007\007\007\007text' | + text | + {6:Press ENTER or type command to continue}^ | + ]], condition = function() eq(true, screen.bell) end, @@ -199,17 +189,17 @@ describe('shell command :!', function() screen.bell = false screen:expect { grid = [[ - | - {1:~ }| - {3: }| - :!cat test/functional/fixtures/shell_data.txt | - ^@^A^B^C^D^E^F^H | - ^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\^]^^^_ | - ö 한글 | - t | - | - {6:Press ENTER or type command to continue}^ | - ]], + | + {1:~ }| + {3: }| + :!cat test/functional/fixtures/shell_data.txt | + ^@^A^B^C^D^E^F^H | + ^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\^]^^^_ | + ö 한글 | + t | + | + {6:Press ENTER or type command to continue}^ | + ]], condition = function() eq(true, screen.bell) end,