diff options
Diffstat (limited to 'test/functional/ui/screen_basic_spec.lua')
-rw-r--r-- | test/functional/ui/screen_basic_spec.lua | 624 |
1 files changed, 183 insertions, 441 deletions
diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 7cc1accd3f..42e2b4d4b5 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -4,39 +4,39 @@ local spawn, set_session, clear = helpers.spawn, helpers.set_session, helpers.cl local feed, command = helpers.feed, helpers.command local insert = helpers.insert local eq = helpers.eq -local funcs, meths = helpers.funcs, helpers.meths +local fn, api = helpers.fn, helpers.api describe('screen', function() local screen - local nvim_argv = {helpers.nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N', - '--cmd', 'set shortmess+=I background=light noswapfile belloff= noshowcmd noruler', - '--embed'} + local nvim_argv = { + helpers.nvim_prog, + '-u', + 'NONE', + '-i', + 'NONE', + '-n', + '--cmd', + 'set shortmess+=I background=light noswapfile belloff= noshowcmd noruler', + '--cmd', + 'colorscheme vim', + '--embed', + } before_each(function() local screen_nvim = spawn(nvim_argv) set_session(screen_nvim) screen = Screen.new() screen:attach() - screen:set_default_attr_ids( { - [0] = {bold=true, foreground=255}, - [1] = {bold=true, reverse=true}, - } ) + screen:set_default_attr_ids({ + [0] = { bold = true, foreground = 255 }, + [1] = { bold = true, reverse = true }, + }) end) it('default initial screen', function() - screen:expect([[ + screen:expect([[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*11 {1:[No Name] }| | ]]) @@ -49,18 +49,23 @@ local function screen_tests(linegrid) before_each(function() clear() screen = Screen.new() - screen:attach({rgb=true,ext_linegrid=linegrid}) - screen:set_default_attr_ids( { - [0] = {bold=true, foreground=255}, - [1] = {bold=true, reverse=true}, - [2] = {bold=true}, - [3] = {reverse=true}, - [4] = {background = Screen.colors.LightGrey, underline = true}, - [5] = {background = Screen.colors.LightGrey, underline = true, bold = true, foreground = Screen.colors.Fuchsia}, - [6] = {bold = true, foreground = Screen.colors.Fuchsia}, - [7] = {bold = true, foreground = Screen.colors.SeaGreen}, - [8] = {foreground = Screen.colors.White, background = Screen.colors.Red}, - } ) + screen:attach({ rgb = true, ext_linegrid = linegrid }) + screen:set_default_attr_ids({ + [0] = { bold = true, foreground = 255 }, + [1] = { bold = true, reverse = true }, + [2] = { bold = true }, + [3] = { reverse = true }, + [4] = { background = Screen.colors.LightGrey, underline = true }, + [5] = { + background = Screen.colors.LightGrey, + underline = true, + bold = true, + foreground = Screen.colors.Fuchsia, + }, + [6] = { bold = true, foreground = Screen.colors.Fuchsia }, + [7] = { bold = true, foreground = Screen.colors.SeaGreen }, + [8] = { foreground = Screen.colors.White, background = Screen.colors.Red }, + }) end) describe('bell/visual bell', function() @@ -83,7 +88,7 @@ local function screen_tests(linegrid) describe(':set title', function() it('is forwarded to the UI', function() local expected = 'test-title' - command('set titlestring='..expected) + command('set titlestring=' .. expected) command('set title') screen:expect(function() eq(expected, screen.title) @@ -100,7 +105,7 @@ local function screen_tests(linegrid) describe(':set icon', function() it('is forwarded to the UI', function() local expected = 'test-icon' - command('set iconstring='..expected) + command('set iconstring=' .. expected) command('set icon') screen:expect(function() eq(expected, screen.icon) @@ -119,74 +124,46 @@ local function screen_tests(linegrid) command('set laststatus=2') screen:expect([[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*11 {1:[No Name] }| | ]]) feed('<c-l>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*11 {1:[No Name] }| | - ]], reset=true} + ]], + reset = true, + } command('split') screen:expect([[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 {1:[No Name] }| | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {3:[No Name] }| | ]]) feed('<c-l>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 {1:[No Name] }| | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {3:[No Name] }| | - ]], reset=true} + ]], + reset = true, + } end) end) @@ -196,17 +173,10 @@ local function screen_tests(linegrid) command('sp') screen:expect([[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 {1:[No Name] }| | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {3:[No Name] }| | ]]) @@ -217,17 +187,10 @@ local function screen_tests(linegrid) command('resize 8') screen:expect([[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*7 {1:[No Name] }| | - {0:~ }| - {0:~ }| + {0:~ }|*2 {3:[No Name] }| | ]]) @@ -239,34 +202,20 @@ local function screen_tests(linegrid) command('vsp') screen:expect([[ ^ │ │ | - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }|*5 {1:[No Name] }{3:[No Name] [No Name] }| | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {3:[No Name] }| | ]]) insert('hello') screen:expect([[ hell^o │hello │hello | - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }|*5 {1:[No Name] [+] }{3:[No Name] [+] [No Name] [+] }| hello | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {3:[No Name] [+] }| | ]]) @@ -282,17 +231,10 @@ local function screen_tests(linegrid) insert('hello') screen:expect([[ hell^o │hello │hello | - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }|*5 {1:[No Name] [+] }{3:[No Name] [+] [No Name] [+] }| hello | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {3:[No Name] [+] }| | ]]) @@ -302,33 +244,17 @@ local function screen_tests(linegrid) screen:expect([[ {4: }{5:4}{4:+ [No Name] }{2: + [No Name] }{3: }{4:X}| hell^o2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*11 | ]]) command('tabprevious') screen:expect([[ {2: }{6:4}{2:+ [No Name] }{4: + [No Name] }{3: }{4:X}| hell^o │hello │hello | - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }|*5 {1:[No Name] [+] }{3:[No Name] [+] [No Name] [+] }| hello | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {3:[No Name] [+] }| | ]]) @@ -339,34 +265,14 @@ local function screen_tests(linegrid) screen:expect([[ {4: [No Name] }{2: [No Name] }{3: }{4:X}| ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*11 | ]]) - feed(':echo "'..string.rep('x\\n', 11)..'"<cr>') + feed(':echo "' .. string.rep('x\\n', 11) .. '"<cr>') screen:expect([[ {1: }| - x | - x | - x | - x | - x | - x | - x | - x | - x | - x | - x | + x |*11 | {7:Press ENTER or type command to continue}^ | ]]) @@ -375,34 +281,13 @@ local function screen_tests(linegrid) screen:expect([[ {4: [No Name] }{2: [No Name] }{3: }{4:X}| ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*11 | ]]) - feed(':echo "'..string.rep('x\\n', 12)..'"<cr>') + feed(':echo "' .. string.rep('x\\n', 12) .. '"<cr>') screen:expect([[ - x | - x | - x | - x | - x | - x | - x | - x | - x | - x | - x | - x | + x |*12 | {7:Press ENTER or type command to continue}^ | ]]) @@ -411,20 +296,9 @@ local function screen_tests(linegrid) screen:expect([[ {4: [No Name] }{2: [No Name] }{3: }{4:X}| ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*11 | ]]) - end) it('redraws properly with :tab split right after scroll', function() @@ -433,17 +307,7 @@ local function screen_tests(linegrid) command('vsplit') screen:expect([[ ^foo │foo | - foo │foo | - foo │foo | - foo │foo | - foo │foo | - foo │foo | - foo │foo | - foo │foo | - foo │foo | - foo │foo | - foo │foo | - foo │foo | + foo │foo |*11 {1:[No Name] [+] }{3:[No Name] [+] }| | ]]) @@ -451,17 +315,8 @@ local function screen_tests(linegrid) feed('<PageDown>') screen:expect([[ ^foo │foo | - foo │foo | - foo │foo | - foo │foo | - bar │foo | - bar │foo | - bar │foo | - bar │foo | - bar │foo | - bar │foo | - bar │foo | - bar │foo | + foo │foo |*3 + bar │foo |*8 {1:[No Name] [+] }{3:[No Name] [+] }| | ]]) @@ -469,17 +324,8 @@ local function screen_tests(linegrid) screen:expect([[ {4: }{5:2}{4:+ [No Name] }{2: + [No Name] }{3: }{4:X}| ^foo | - foo | - foo | - foo | - bar | - bar | - bar | - bar | - bar | - bar | - bar | - bar | + foo |*3 + bar |*8 | ]]) end) @@ -491,17 +337,7 @@ local function screen_tests(linegrid) screen:expect([[ {2: + [No Name] }{4: [No Name] }{3: }{4:X}| hell^o | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*11 | ]]) @@ -509,17 +345,7 @@ local function screen_tests(linegrid) screen:expect([[ {4: + [No Name] }{2: [No Name] }{3: }{4:X}| ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*11 | ]]) end) @@ -532,16 +358,7 @@ local function screen_tests(linegrid) line 1 | line 2 | ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*10 {2:-- INSERT --} | ]]) end) @@ -557,17 +374,7 @@ local function screen_tests(linegrid) screen:expect([[ 0123^456 | 789 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*11 1,5 All | ]]) end) @@ -578,18 +385,7 @@ local function screen_tests(linegrid) feed(':ls') screen:expect([[ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*12 :ls^ | ]]) end) @@ -598,15 +394,7 @@ local function screen_tests(linegrid) feed(':ls<cr>') screen:expect([[ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*9 {1: }| :ls | 1 %a "[No Name]" line 1 | @@ -783,9 +571,7 @@ local function screen_tests(linegrid) feed('iresize') screen:expect([[ resize^ | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {2:-- INSERT --} | ]]) end) @@ -811,38 +597,27 @@ local function screen_tests(linegrid) command([[autocmd VimResized * redrawtabline]]) command([[autocmd VimResized * lua vim.api.nvim_echo({ { 'Hello' } }, false, {})]]) command([[autocmd VimResized * let g:echospace = v:echospace]]) - meths.set_option_value('showtabline', 2, {}) + api.nvim_set_option_value('showtabline', 2, {}) screen:expect([[ {2: + [No Name] }{3: }| resiz^e | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) screen:try_resize(30, 6) screen:expect([[ {2: + [No Name] }{3: }| resiz^e | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) - eq(29, meths.get_var('echospace')) + eq(29, api.nvim_get_var('echospace')) end) it('messages from the same Ex command as resize are visible #22225', function() feed(':set columns=20 | call<CR>') screen:expect([[ - | - | - | - | - | - | - | - | - | + |*9 {1: }| {8:E471: Argument requi}| {8:red} | @@ -852,53 +627,25 @@ local function screen_tests(linegrid) feed('<CR>') screen:expect([[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*12 | ]]) feed(':set columns=0<CR>') screen:expect([[ - | - | - | - | - | - {1: }| - {8:E594: Need a}| - {8:t least 12 c}| - {8:olumns: colu}| - {8:mns=0} | - {7:Press ENTER }| - {7:or type comm}| - {7:and to conti}| - {7:nue}^ | + | + {0:~ }|*7 + {1: }| + {8:E594: Need at least }| + {8:12 columns: columns=}| + {8:0} | + {7:Press ENTER or type }| + {7:command to continue}^ | ]]) feed('<CR>') screen:expect([[ - ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - | + ^ | + {0:~ }|*12 + | ]]) end) end) @@ -909,15 +656,7 @@ local function screen_tests(linegrid) feed(':ls<CR>') screen:expect([[ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*9 {1: }| :ls | 1 %a "[No Name]" line 1 | @@ -926,18 +665,7 @@ local function screen_tests(linegrid) feed('<F1>') screen:expect([[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*12 TEST | ]]) end) @@ -950,45 +678,23 @@ local function screen_tests(linegrid) feed('ifooj') screen:expect([[ foo^j | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*12 {2:-- INSERT --} | ]]) feed('k') screen:expect([[ fo^o | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*12 | ]]) end) end -describe("Screen (char-based)", function() +describe('Screen (char-based)', function() screen_tests(false) end) -describe("Screen (line-based)", function() +describe('Screen (line-based)', function() screen_tests(true) end) @@ -997,41 +703,75 @@ describe('Screen default colors', function() local function startup(light, termcolors) local extra = (light and ' background=light') or '' - local nvim_argv = {helpers.nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N', - '--cmd', 'set shortmess+=I noswapfile belloff= noshowcmd noruler'..extra, - '--embed'} + local nvim_argv = { + helpers.nvim_prog, + '-u', + 'NONE', + '-i', + 'NONE', + '-N', + '--cmd', + 'set shortmess+=I noswapfile belloff= noshowcmd noruler' .. extra, + '--cmd', + 'colorscheme vim', + '--embed', + } local screen_nvim = spawn(nvim_argv) set_session(screen_nvim) screen = Screen.new() - screen:attach(termcolors and {rgb=true,ext_termcolors=true} or {rgb=true}) + screen:attach(termcolors and { rgb = true, ext_termcolors = true } or { rgb = true }) end it('are dark per default', function() startup(false, false) - screen:expect{condition=function() - eq({rgb_bg=0, rgb_fg=Screen.colors.White, rgb_sp=Screen.colors.Red, - cterm_bg=0, cterm_fg=0}, screen.default_colors) - end} + screen:expect { + condition = function() + eq({ + rgb_bg = 0, + rgb_fg = Screen.colors.White, + rgb_sp = Screen.colors.Red, + cterm_bg = 0, + cterm_fg = 0, + }, screen.default_colors) + end, + } end) it('can be set to light', function() startup(true, false) - screen:expect{condition=function() - eq({rgb_fg=Screen.colors.White, rgb_bg=0, rgb_sp=Screen.colors.Red, - cterm_bg=0, cterm_fg=0}, screen.default_colors) - end} + screen:expect { + condition = function() + eq({ + rgb_bg = Screen.colors.White, + rgb_fg = 0, + rgb_sp = Screen.colors.Red, + cterm_bg = 0, + cterm_fg = 0, + }, screen.default_colors) + end, + } end) it('can be handled by external terminal', function() startup(false, true) - screen:expect{condition=function() - eq({rgb_bg=-1, rgb_fg=-1, rgb_sp=-1, cterm_bg=0, cterm_fg=0}, screen.default_colors) - end} + screen:expect { + condition = function() + eq( + { rgb_bg = -1, rgb_fg = -1, rgb_sp = -1, cterm_bg = 0, cterm_fg = 0 }, + screen.default_colors + ) + end, + } startup(true, true) - screen:expect{condition=function() - eq({rgb_bg=-1, rgb_fg=-1, rgb_sp=-1, cterm_bg=0, cterm_fg=0}, screen.default_colors) - end} + screen:expect { + condition = function() + eq( + { rgb_bg = -1, rgb_fg = -1, rgb_sp = -1, cterm_bg = 0, cterm_fg = 0 }, + screen.default_colors + ) + end, + } end) end) @@ -1039,46 +779,48 @@ it('CTRL-F or CTRL-B scrolls a page after UI attach/resize #20605', function() clear() local screen = Screen.new(100, 100) screen:attach() - eq(100, meths.get_option_value('lines', {})) - eq(99, meths.get_option_value('window', {})) - eq(99, meths.win_get_height(0)) + eq(100, api.nvim_get_option_value('lines', {})) + eq(99, api.nvim_get_option_value('window', {})) + eq(99, api.nvim_win_get_height(0)) feed('1000o<Esc>') - eq(903, funcs.line('w0')) + eq(903, fn.line('w0')) feed('<C-B>') - eq(806, funcs.line('w0')) + eq(806, fn.line('w0')) feed('<C-B>') - eq(709, funcs.line('w0')) + eq(709, fn.line('w0')) feed('<C-F>') - eq(806, funcs.line('w0')) + eq(806, fn.line('w0')) feed('<C-F>') - eq(903, funcs.line('w0')) + eq(903, fn.line('w0')) feed('G') screen:try_resize(50, 50) - eq(50, meths.get_option_value('lines', {})) - eq(49, meths.get_option_value('window', {})) - eq(49, meths.win_get_height(0)) - eq(953, funcs.line('w0')) + eq(50, api.nvim_get_option_value('lines', {})) + eq(49, api.nvim_get_option_value('window', {})) + eq(49, api.nvim_win_get_height(0)) + eq(953, fn.line('w0')) feed('<C-B>') - eq(906, funcs.line('w0')) + eq(906, fn.line('w0')) feed('<C-B>') - eq(859, funcs.line('w0')) + eq(859, fn.line('w0')) feed('<C-F>') - eq(906, funcs.line('w0')) + eq(906, fn.line('w0')) feed('<C-F>') - eq(953, funcs.line('w0')) + eq(953, fn.line('w0')) end) it("showcmd doesn't cause empty grid_line with redrawdebug=compositor #22593", function() clear() local screen = Screen.new(30, 2) screen:set_default_attr_ids({ - [0] = {bold = true, foreground = Screen.colors.Blue}, + [0] = { bold = true, foreground = Screen.colors.Blue }, }) screen:attach() command('set showcmd redrawdebug=compositor') feed('d') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | d | - ]]} + ]], + } end) |