diff options
Diffstat (limited to 'test/functional')
26 files changed, 1762 insertions, 427 deletions
diff --git a/test/functional/api/autocmd_spec.lua b/test/functional/api/autocmd_spec.lua index 41de308a2c..491dac9f35 100644 --- a/test/functional/api/autocmd_spec.lua +++ b/test/functional/api/autocmd_spec.lua @@ -119,13 +119,45 @@ describe('autocmd api', function() describe('desc', function() it('can add description to one autocmd', function() + local cmd = "echo 'Should Not Have Errored'" + local desc = "Can show description" meths.create_autocmd("BufReadPost", { pattern = "*.py", - command = "echo 'Should Not Have Errored'", - desc = "Can show description", + command = cmd, + desc = desc, }) - eq("Can show description", meths.get_autocmds { event = "BufReadPost" }[1].desc) + eq(desc, meths.get_autocmds { event = "BufReadPost" }[1].desc) + eq(cmd, meths.get_autocmds { event = "BufReadPost" }[1].command) + end) + + it('can add description to one autocmd that uses a callback', function() + local desc = 'Can show description' + meths.set_var('desc', desc) + + exec_lua([[ + local callback = function() print 'Should Not Have Errored' end + vim.api.nvim_create_autocmd("BufReadPost", { + pattern = "*.py", + callback = callback, + desc = vim.g.desc, + }) + ]]) + + eq(desc, meths.get_autocmds({ event = 'BufReadPost' })[1].desc) + matches('<lua: %d+>', meths.get_autocmds({ event = 'BufReadPost' })[1].command) + end) + + it('will not add a description unless it was provided', function() + exec_lua([[ + local callback = function() print 'Should Not Have Errored' end + vim.api.nvim_create_autocmd("BufReadPost", { + pattern = "*.py", + callback = callback, + }) + ]]) + + eq(nil, meths.get_autocmds({ event = 'BufReadPost' })[1].desc) end) it('can add description to multiple autocmd', function() @@ -169,15 +201,11 @@ describe('autocmd api', function() ]] meths.exec_autocmds("User", {pattern = "Test"}) - eq({{ - buflocal = false, - command = 'A test autocommand', - desc = 'A test autocommand', - event = 'User', - id = 1, - once = false, - pattern = 'Test', - }}, meths.get_autocmds({event = "User", pattern = "Test"})) + + local aus = meths.get_autocmds({ event = 'User', pattern = 'Test' }) + local first = aus[1] + eq(first.id, 1) + meths.set_var("some_condition", true) meths.exec_autocmds("User", {pattern = "Test"}) eq({}, meths.get_autocmds({event = "User", pattern = "Test"})) @@ -230,6 +258,34 @@ describe('autocmd api', function() }, meths.get_var("autocmd_args")) end) + + it('can receive arbitrary data', function() + local function test(data) + eq(data, exec_lua([[ + local input = ... + local output + vim.api.nvim_create_autocmd("User", { + pattern = "Test", + callback = function(args) + output = args.data + end, + }) + + vim.api.nvim_exec_autocmds("User", { + pattern = "Test", + data = input, + }) + + return output + ]], data)) + end + + test("Hello") + test(42) + test(true) + test({ "list" }) + test({ foo = "bar" }) + end) end) describe('nvim_get_autocmds', function() diff --git a/test/functional/api/buffer_updates_spec.lua b/test/functional/api/buffer_updates_spec.lua index fc09e4cde0..2728dcf74c 100644 --- a/test/functional/api/buffer_updates_spec.lua +++ b/test/functional/api/buffer_updates_spec.lua @@ -785,7 +785,8 @@ describe('API: buffer events:', function() local function lines_subset(first, second) for i = 1,#first do - if first[i] ~= second[i] then + -- need to ignore trailing spaces + if first[i]:gsub(' +$', '') ~= second[i]:gsub(' +$', '') then return false end end @@ -827,7 +828,6 @@ describe('API: buffer events:', function() end it('when :terminal lines change', function() - if helpers.pending_win32(pending) then return end local buffer_lines = {} local expected_lines = {} command('terminal "'..nvim_prog..'" -u NONE -i NONE -n -c "set shortmess+=A"') diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 8c4048132c..55535a92e5 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -3120,6 +3120,19 @@ describe('API', function() 'TextWithNoHighlight%#WarningMsg#TextWithWarningHighlight', { use_tabline = true, highlights = true })) end) + it('works with winbar', function() + eq({ + str = 'TextWithNoHighlightTextWithWarningHighlight', + width = 43, + highlights = { + { start = 0, group = 'WinBar' }, + { start = 19, group = 'WarningMsg' } + } + }, + meths.eval_statusline( + 'TextWithNoHighlight%#WarningMsg#TextWithWarningHighlight', + { use_winbar = true, highlights = true })) + end) end) end) describe('nvim_parse_cmd', function() @@ -3641,5 +3654,13 @@ describe('API', function() meths.cmd({ cmd = "update" }, {}) meths.cmd({ cmd = "buffer", count = 0 }, {}) end) + it('doesn\'t suppress errors when used in keymapping', function() + meths.exec_lua([[ + vim.keymap.set("n", "[l", + function() vim.api.nvim_cmd({ cmd = "echo", args = {"foo"} }, {}) end) + ]], {}) + feed("[l") + neq(nil, string.find(eval("v:errmsg"), "E5108:")) + end) end) end) diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua index 20ea3621f0..f87fd8e951 100644 --- a/test/functional/core/startup_spec.lua +++ b/test/functional/core/startup_spec.lua @@ -53,7 +53,6 @@ describe('startup', function() ]]) end) it('in a TTY: has("ttyin")==1 has("ttyout")==1', function() - if helpers.pending_win32(pending) then return end local screen = Screen.new(25, 4) screen:attach() if iswin() then @@ -105,7 +104,6 @@ describe('startup', function() end) end) it('input from pipe (implicit) #7679', function() - if helpers.pending_win32(pending) then return end local screen = Screen.new(25, 4) screen:attach() if iswin() then @@ -261,7 +259,6 @@ describe('startup', function() end) it('ENTER dismisses early message #7967', function() - if helpers.pending_win32(pending) then return end local screen screen = Screen.new(60, 6) screen:attach() @@ -494,14 +491,14 @@ describe('sysinit', function() end) it('fixed hang issue with -D (#12647)', function() - if helpers.pending_win32(pending) then return end local screen - screen = Screen.new(60, 6) + screen = Screen.new(60, 7) screen:attach() command([[let g:id = termopen('"]]..nvim_prog.. [[" -u NONE -i NONE --cmd "set noruler" -D')]]) screen:expect([[ ^ | + | Entering Debug mode. Type "cont" to continue. | cmd: augroup nvim_terminal | > | @@ -512,6 +509,7 @@ describe('sysinit', function() screen:expect([[ ^ | ~ | + ~ | [No Name] | | <" -u NONE -i NONE --cmd "set noruler" -D 1,0-1 All| diff --git a/test/functional/editor/mode_insert_spec.lua b/test/functional/editor/mode_insert_spec.lua index 684dee69db..e3d3cdbd85 100644 --- a/test/functional/editor/mode_insert_spec.lua +++ b/test/functional/editor/mode_insert_spec.lua @@ -6,8 +6,6 @@ local expect = helpers.expect local command = helpers.command local eq = helpers.eq local eval = helpers.eval -local meths = helpers.meths -local poke_eventloop = helpers.poke_eventloop describe('insert-mode', function() before_each(function() @@ -135,26 +133,4 @@ describe('insert-mode', function() feed('i<C-S-V><C-J><C-S-V><C-@><C-S-V><C-[><C-S-V><C-S-M><C-S-V><M-C-I><C-S-V><C-D-J><Esc>') expect('<C-J><C-@><C-[><C-S-M><M-C-I><C-D-J>') end) - - describe([[With 'insertmode', Insert mode is not re-entered immediately after <C-L>]], function() - before_each(function() - command('set insertmode') - poke_eventloop() - eq({mode = 'i', blocking = false}, meths.get_mode()) - end) - - it('after calling :edit from <Cmd> mapping', function() - command('inoremap <C-B> <Cmd>edit Xfoo<CR>') - feed('<C-B><C-L>') - poke_eventloop() - eq({mode = 'n', blocking = false}, meths.get_mode()) - end) - - it('after calling :edit from RPC #16823', function() - command('edit Xfoo') - feed('<C-L>') - poke_eventloop() - eq({mode = 'n', blocking = false}, meths.get_mode()) - end) - end) end) diff --git a/test/functional/ex_cmds/mksession_spec.lua b/test/functional/ex_cmds/mksession_spec.lua index 2702fb196f..8323d40e10 100644 --- a/test/functional/ex_cmds/mksession_spec.lua +++ b/test/functional/ex_cmds/mksession_spec.lua @@ -1,20 +1,23 @@ local lfs = require('lfs') local helpers = require('test.functional.helpers')(after_each) +local Screen = require('test.functional.ui.screen') local clear = helpers.clear local command = helpers.command local get_pathsep = helpers.get_pathsep +local iswin = helpers.iswin local eq = helpers.eq local neq = helpers.neq local funcs = helpers.funcs local matches = helpers.matches local pesc = helpers.pesc local rmdir = helpers.rmdir +local sleep = helpers.sleep +local meths = helpers.meths local file_prefix = 'Xtest-functional-ex_cmds-mksession_spec' describe(':mksession', function() - if helpers.pending_win32(pending) then return end local session_file = file_prefix .. '.vim' local tab_dir = file_prefix .. '.d' @@ -103,9 +106,13 @@ describe(':mksession', function() local session_path = cwd_dir..'/'..session_file command('cd '..tab_dir) - command('terminal echo $PWD') + command('terminal') command('cd '..cwd_dir) command('mksession '..session_path) + command('bdelete!') + if iswin() then + sleep(100) -- Make sure all child processes have exited. + end command('qall!') -- Create a new test instance of Nvim. @@ -114,6 +121,83 @@ describe(':mksession', function() local expected_cwd = cwd_dir..'/'..tab_dir matches('^term://'..pesc(expected_cwd)..'//%d+:', funcs.expand('%')) + command('bdelete!') + if iswin() then + sleep(100) -- Make sure all child processes have exited. + end + end) + + it('restores CWD for :terminal buffer at root directory #16988', function() + if iswin() then + pending('N/A for Windows') + return + end + + local screen + local cwd_dir = funcs.fnamemodify('.', ':p:~'):gsub([[[\/]*$]], '') + local session_path = cwd_dir..'/'..session_file + + screen = Screen.new(50, 6) + screen:attach({rgb=false}) + local expected_screen = [[ + ^/ | + | + [Process exited 0] | + | + | + | + ]] + + command('cd /') + command('terminal echo $PWD') + + -- Verify that the terminal's working directory is "/". + screen:expect(expected_screen) + + command('cd '..cwd_dir) + command('mksession '..session_path) command('qall!') + + -- Create a new test instance of Nvim. + clear() + screen = Screen.new(50, 6) + screen:attach({rgb=false}) + command('silent source '..session_path) + + -- Verify that the terminal's working directory is "/". + screen:expect(expected_screen) + end) + + it('restores a session when there is a float #18432', function() + local tmpfile = file_prefix .. '-tmpfile-float' + + command('edit ' .. tmpfile) + local buf = meths.create_buf(false, true) + local config = { + relative = 'editor', + focusable = false, + width = 10, + height = 3, + row = 0, + col = 1, + style = 'minimal' + } + meths.open_win(buf, false, config) + local cmdheight = meths.get_option('cmdheight') + command('mksession ' .. session_file) + + -- Create a new test instance of Nvim. + clear() + + command('source ' .. session_file) + + eq(tmpfile, funcs.expand('%')) + -- Check that there is only a single window, which indicates the floating + -- window was not restored. + eq(1, funcs.winnr('$')) + -- The command-line height should remain the same as it was. + eq(cmdheight, meths.get_option('cmdheight')) + + os.remove(tmpfile) end) end) diff --git a/test/functional/legacy/edit_spec.lua b/test/functional/legacy/edit_spec.lua deleted file mode 100644 index 91d602924c..0000000000 --- a/test/functional/legacy/edit_spec.lua +++ /dev/null @@ -1,25 +0,0 @@ --- Test for edit functions --- See also: src/nvim/testdir/test_edit.vim - -local helpers = require('test.functional.helpers')(after_each) -local source = helpers.source -local eq, eval = helpers.eq, helpers.eval -local funcs = helpers.funcs -local clear = helpers.clear - -describe('edit', function() - before_each(clear) - - it('reset insertmode from i_ctrl-r_=', function() - source([=[ - call setline(1, ['abc']) - call cursor(1, 4) - call feedkeys(":set im\<cr>ZZZ\<c-r>=setbufvar(1,'&im', 0)\<cr>",'tnix') - ]=]) - eq({'abZZZc'}, funcs.getline(1,'$')) - eq({0, 1, 1, 0}, funcs.getpos('.')) - eq(0, eval('&im')) - end) - -end) - diff --git a/test/functional/legacy/prompt_buffer_spec.lua b/test/functional/legacy/prompt_buffer_spec.lua index 47eca19de3..63338b8dba 100644 --- a/test/functional/legacy/prompt_buffer_spec.lua +++ b/test/functional/legacy/prompt_buffer_spec.lua @@ -23,7 +23,7 @@ describe('prompt buffer', function() close else call append(line("$") - 1, 'Command: "' . a:text . '"') - set nomodfied + set nomodified call timer_start(20, {id -> TimerFunc(a:text)}) endif endfunc @@ -33,7 +33,7 @@ describe('prompt buffer', function() endfunc func SwitchWindows() - call timer_start(0, {-> execute("wincmd p|wincmd p", "")}) + call timer_start(0, {-> execute("wincmd p", "")}) endfunc ]]) feed_command("set noshowmode | set laststatus=0") @@ -187,7 +187,19 @@ describe('prompt buffer', function() -- INSERT -- | ]]) feed("<C-O>:call SwitchWindows()<CR>") - poke_eventloop() + screen:expect{grid=[[ + cmd: | + ~ | + ~ | + ~ | + [Prompt] [+] | + ^other buffer | + ~ | + ~ | + ~ | + | + ]]} + feed("<C-O>:call SwitchWindows()<CR>") screen:expect([[ cmd: ^ | ~ | @@ -201,7 +213,6 @@ describe('prompt buffer', function() -- INSERT -- | ]]) feed("<Esc>") - poke_eventloop() screen:expect([[ cmd:^ | ~ | diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua index 4cb7636825..f8d4552330 100644 --- a/test/functional/plugin/lsp_spec.lua +++ b/test/functional/plugin/lsp_spec.lua @@ -18,6 +18,7 @@ local NIL = helpers.NIL local read_file = require('test.helpers').read_file local write_file = require('test.helpers').write_file local isCI = helpers.isCI +local meths = helpers.meths -- Use these to get access to a coroutine so that I can run async tests and use -- yield. @@ -221,10 +222,32 @@ describe('LSP', function() end) end) + describe('lsp._cmd_parts test', function() + local function _cmd_parts(input) + return exec_lua([[ + lsp = require('vim.lsp') + return lsp._cmd_parts(...) + ]], input) + end + it('should valid cmd argument', function() + eq(true, pcall(_cmd_parts, {"nvim"})) + eq(true, pcall(_cmd_parts, {"nvim", "--head"})) + end) + + it('should invalid cmd argument', function() + eq('Error executing lua: .../lsp.lua:0: cmd: expected list, got nvim', + pcall_err(_cmd_parts, 'nvim')) + eq('Error executing lua: .../lsp.lua:0: cmd argument: expected string, got number', + pcall_err(_cmd_parts, {'nvim', 1})) + end) + end) +end) + +describe('LSP', function() describe('basic_init test', function() after_each(function() stop() - exec_lua("lsp.stop_client(lsp.get_active_clients())") + exec_lua("lsp.stop_client(lsp.get_active_clients(), true)") exec_lua("lsp._vim_exit_handler()") end) @@ -341,6 +364,43 @@ describe('LSP', function() } end) + it('should fire autocommands on attach and detach', function() + local client + test_rpc_server { + test_name = "basic_init"; + on_setup = function() + exec_lua [[ + BUFFER = vim.api.nvim_create_buf(false, true) + vim.api.nvim_create_autocmd('LspAttach', { + callback = function(args) + local client = vim.lsp.get_client_by_id(args.data.client_id) + vim.g.lsp_attached = client.name + end, + }) + vim.api.nvim_create_autocmd('LspDetach', { + callback = function(args) + local client = vim.lsp.get_client_by_id(args.data.client_id) + vim.g.lsp_detached = client.name + end, + }) + ]] + end; + on_init = function(_client) + client = _client + eq(true, exec_lua("return lsp.buf_attach_client(BUFFER, TEST_RPC_CLIENT_ID)")) + client.notify('finish') + end; + on_handler = function(_, _, ctx) + if ctx.method == 'finish' then + eq('basic_init', meths.get_var('lsp_attached')) + exec_lua("return lsp.buf_detach_client(BUFFER, TEST_RPC_CLIENT_ID)") + eq('basic_init', meths.get_var('lsp_detached')) + client.stop() + end + end; + } + end) + it('client should return settings via workspace/configuration handler', function() local expected_handlers = { {NIL, {}, {method="shutdown", client_id=1}}; @@ -386,16 +446,23 @@ describe('LSP', function() } end) it('workspace/configuration returns NIL per section if client was started without config.settings', function() - fake_lsp_server_setup('workspace/configuration no settings') - eq({ NIL, NIL, }, exec_lua [[ - local result = { - items = { - {section = 'foo'}, - {section = 'bar'}, - } - } - return vim.lsp.handlers['workspace/configuration'](nil, result, {client_id=TEST_RPC_CLIENT_ID}) - ]]) + local result = nil + test_rpc_server { + test_name = 'basic_init'; + on_init = function(c) c.stop() end, + on_setup = function() + result = exec_lua [[ + local result = { + items = { + {section = 'foo'}, + {section = 'bar'}, + } + } + return vim.lsp.handlers['workspace/configuration'](nil, result, {client_id=TEST_RPC_CLIENT_ID}) + ]] + end + } + eq({ NIL, NIL }, result) end) it('should verify capabilities sent', function() @@ -1307,25 +1374,6 @@ describe('LSP', function() } end) end) - describe('lsp._cmd_parts test', function() - local function _cmd_parts(input) - return exec_lua([[ - lsp = require('vim.lsp') - return lsp._cmd_parts(...) - ]], input) - end - it('should valid cmd argument', function() - eq(true, pcall(_cmd_parts, {"nvim"})) - eq(true, pcall(_cmd_parts, {"nvim", "--head"})) - end) - - it('should invalid cmd argument', function() - eq('Error executing lua: .../lsp.lua:0: cmd: expected list, got nvim', - pcall_err(_cmd_parts, 'nvim')) - eq('Error executing lua: .../lsp.lua:0: cmd argument: expected string, got number', - pcall_err(_cmd_parts, {'nvim', 1})) - end) - end) end) describe('LSP', function() diff --git a/test/functional/terminal/cursor_spec.lua b/test/functional/terminal/cursor_spec.lua index 3b905f1f56..6e06304acd 100644 --- a/test/functional/terminal/cursor_spec.lua +++ b/test/functional/terminal/cursor_spec.lua @@ -5,6 +5,7 @@ local feed, clear, nvim = helpers.feed, helpers.clear, helpers.nvim local nvim_dir, command = helpers.nvim_dir, helpers.command local nvim_prog = helpers.nvim_prog local eq, eval = helpers.eq, helpers.eval +local matches = helpers.matches local feed_command = helpers.feed_command local hide_cursor = thelpers.hide_cursor local show_cursor = thelpers.show_cursor @@ -177,7 +178,6 @@ describe('cursor with customized highlighting', function() end) describe('buffer cursor position is correct in terminal without number column', function() - if helpers.pending_win32(pending) then return end local screen local function setup_ex_register(str) @@ -525,10 +525,36 @@ describe('buffer cursor position is correct in terminal without number column', eq({6, 1}, eval('nvim_win_get_cursor(0)')) end) end) + + it('at the end of a line with trailing spaces #16234', function() + setup_ex_register('aaaaaaaa ') + feed('<C-R>r') + screen:expect([[ + | + | + | + | + Entering Ex mode. Type "visual" to go to Normal mode. | + :aaaaaaaa {1: } | + {3:-- TERMINAL --} | + ]]) + matches('^:aaaaaaaa [ ]*$', eval('nvim_get_current_line()')) + eq({6, 13}, eval('nvim_win_get_cursor(0)')) + feed([[<C-\><C-N>]]) + screen:expect([[ + | + | + | + | + Entering Ex mode. Type "visual" to go to Normal mode. | + :aaaaaaaa ^ {2: } | + | + ]]) + eq({6, 12}, eval('nvim_win_get_cursor(0)')) + end) end) describe('buffer cursor position is correct in terminal with number column', function() - if helpers.pending_win32(pending) then return end local screen local function setup_ex_register(str) @@ -879,4 +905,31 @@ describe('buffer cursor position is correct in terminal with number column', fun eq({6, 1}, eval('nvim_win_get_cursor(0)')) end) end) + + it('at the end of a line with trailing spaces #16234', function() + setup_ex_register('aaaaaaaa ') + feed('<C-R>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 {1: } | + {3:-- TERMINAL --} | + ]]) + matches('^:aaaaaaaa [ ]*$', eval('nvim_get_current_line()')) + eq({6, 13}, eval('nvim_win_get_cursor(0)')) + feed([[<C-\><C-N>]]) + 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 ^ {2: } | + | + ]]) + eq({6, 12}, eval('nvim_win_get_cursor(0)')) + end) end) diff --git a/test/functional/terminal/highlight_spec.lua b/test/functional/terminal/highlight_spec.lua index 32c911a5e8..2a63971d48 100644 --- a/test/functional/terminal/highlight_spec.lua +++ b/test/functional/terminal/highlight_spec.lua @@ -117,7 +117,6 @@ describe(':terminal highlight', function() end) it(':terminal highlight has lower precedence than editor #9964', function() - if helpers.pending_win32(pending) then return end clear() local screen = Screen.new(30, 4) screen:set_default_attr_ids({ diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua index d1cfc7e91b..34fcb6cab9 100644 --- a/test/functional/terminal/scrollback_spec.lua +++ b/test/functional/terminal/scrollback_spec.lua @@ -6,6 +6,7 @@ local feed, nvim_dir, feed_command = helpers.feed, helpers.nvim_dir, helpers.fee local iswin = helpers.iswin local eval = helpers.eval local command = helpers.command +local matches = helpers.matches local poke_eventloop = helpers.poke_eventloop local retry = helpers.retry local curbufmeths = helpers.curbufmeths @@ -460,8 +461,8 @@ describe("'scrollback' option", function() expect_lines(58) -- Verify off-screen state - eq((iswin() and '36: line' or '35: line'), eval("getline(line('w0') - 1)")) - eq((iswin() and '27: line' or '26: line'), eval("getline(line('w0') - 10)")) + matches((iswin() and '^36: line[ ]*$' or '^35: line[ ]*$'), eval("getline(line('w0') - 1)")) + matches((iswin() and '^27: line[ ]*$' or '^26: line[ ]*$'), eval("getline(line('w0') - 10)")) end) it('defaults to 10000 in :terminal buffers', function() diff --git a/test/functional/ui/bufhl_spec.lua b/test/functional/ui/bufhl_spec.lua index 9f84b71ece..7c0831bd09 100644 --- a/test/functional/ui/bufhl_spec.lua +++ b/test/functional/ui/bufhl_spec.lua @@ -564,6 +564,16 @@ describe('Buffer highlighting', function() ]] clear_namespace(id, 0, -1) + screen:expect{grid=[[ + fooba^r | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} set_extmark(id, 0, 0, { end_line = 0, diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua index 92300a8fa2..d61eebe3ea 100644 --- a/test/functional/ui/cursor_spec.lua +++ b/test/functional/ui/cursor_spec.lua @@ -212,10 +212,10 @@ describe('ui/cursor', function() if m.blinkwait then m.blinkwait = 700 end end if m.hl_id then - m.hl_id = 62 + m.hl_id = 64 m.attr = {background = Screen.colors.DarkGray} end - if m.id_lm then m.id_lm = 63 end + if m.id_lm then m.id_lm = 65 end end -- Assert the new expectation. diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 7ab00e74d9..ca5e269f92 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -6627,7 +6627,7 @@ describe('float window', function() it("left drag changes visual selection in float window", function() local buf = meths.create_buf(false,false) - meths.buf_set_lines(buf, 0, -1, true, {'foo', 'bar'}) + meths.buf_set_lines(buf, 0, -1, true, {'foo', 'bar', 'baz'}) meths.open_win(buf, false, {relative='editor', width=20, height=3, row=2, col=5}) if multigrid then screen:expect{grid=[[ @@ -6651,12 +6651,12 @@ describe('float window', function() ## grid 5 {1:foo }| {1:bar }| - {2:~ }| + {1:baz }| ]], float_pos={ [5] = {{id = 1002}, "NW", 1, 2, 5, true, 50}; }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 2}; + [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3}; }} meths.input_mouse('left', 'press', '', 5, 0, 0) screen:expect{grid=[[ @@ -6680,12 +6680,12 @@ describe('float window', function() ## grid 5 {1:^foo }| {1:bar }| - {2:~ }| + {1:baz }| ]], float_pos={ [5] = {{id = 1002}, "NW", 1, 2, 5, true, 50}; }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 2}; + [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3}; }} meths.input_mouse('left', 'drag', '', 5, 1, 2) screen:expect{grid=[[ @@ -6709,12 +6709,12 @@ describe('float window', function() ## grid 5 {27:foo}{1: }| {27:ba}{1:^r }| - {2:~ }| + {1:baz }| ]], float_pos={ [5] = {{id = 1002}, "NW", 1, 2, 5, true, 50}; }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 2}; + [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 3}; }} else screen:expect{grid=[[ @@ -6722,7 +6722,7 @@ describe('float window', function() {0:~ }| {0:~ }{1:foo }{0: }| {0:~ }{1:bar }{0: }| - {0:~ }{2:~ }{0: }| + {0:~ }{1:baz }{0: }| {0:~ }| | ]]} @@ -6733,7 +6733,7 @@ describe('float window', function() {0:~ }| {0:~ }{1:^foo }{0: }| {0:~ }{1:bar }{0: }| - {0:~ }{2:~ }{0: }| + {0:~ }{1:baz }{0: }| {0:~ }| | ]]} @@ -6744,7 +6744,269 @@ describe('float window', function() {0:~ }| {0:~ }{27:foo}{1: }{0: }| {0:~ }{27:ba}{1:^r }{0: }| - {0:~ }{2:~ }{0: }| + {0:~ }{1:baz }{0: }| + {0:~ }| + {3:-- VISUAL --} | + ]]} + end + end) + + it("left drag changes visual selection in float window with border", function() + local buf = meths.create_buf(false,false) + meths.buf_set_lines(buf, 0, -1, true, {'foo', 'bar', 'baz'}) + meths.open_win(buf, false, {relative='editor', width=20, height=3, row=0, col=5, border='single'}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + ## grid 5 + {5:┌────────────────────┐}| + {5:│}{1:foo }{5:│}| + {5:│}{1:bar }{5:│}| + {5:│}{1:baz }{5:│}| + {5:└────────────────────┘}| + ]], float_pos={ + [5] = {{id = 1002}, "NW", 1, 0, 5, true, 50}; + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3}; + }} + meths.input_mouse('left', 'press', '', 5, 1, 1) + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + ## grid 5 + {5:┌────────────────────┐}| + {5:│}{1:^foo }{5:│}| + {5:│}{1:bar }{5:│}| + {5:│}{1:baz }{5:│}| + {5:└────────────────────┘}| + ]], float_pos={ + [5] = {{id = 1002}, "NW", 1, 0, 5, true, 50}; + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3}; + }} + meths.input_mouse('left', 'drag', '', 5, 2, 3) + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + {3:-- VISUAL --} | + ## grid 5 + {5:┌────────────────────┐}| + {5:│}{27:foo}{1: }{5:│}| + {5:│}{27:ba}{1:^r }{5:│}| + {5:│}{1:baz }{5:│}| + {5:└────────────────────┘}| + ]], float_pos={ + [5] = {{id = 1002}, "NW", 1, 0, 5, true, 50}; + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 3}; + }} + else + screen:expect{grid=[[ + ^ {5:┌────────────────────┐} | + {0:~ }{5:│}{1:foo }{5:│}{0: }| + {0:~ }{5:│}{1:bar }{5:│}{0: }| + {0:~ }{5:│}{1:baz }{5:│}{0: }| + {0:~ }{5:└────────────────────┘}{0: }| + {0:~ }| + | + ]]} + + meths.input_mouse('left', 'press', '', 0, 1, 6) + screen:expect{grid=[[ + {5:┌────────────────────┐} | + {0:~ }{5:│}{1:^foo }{5:│}{0: }| + {0:~ }{5:│}{1:bar }{5:│}{0: }| + {0:~ }{5:│}{1:baz }{5:│}{0: }| + {0:~ }{5:└────────────────────┘}{0: }| + {0:~ }| + | + ]]} + + meths.input_mouse('left', 'drag', '', 0, 2, 8) + screen:expect{grid=[[ + {5:┌────────────────────┐} | + {0:~ }{5:│}{27:foo}{1: }{5:│}{0: }| + {0:~ }{5:│}{27:ba}{1:^r }{5:│}{0: }| + {0:~ }{5:│}{1:baz }{5:│}{0: }| + {0:~ }{5:└────────────────────┘}{0: }| + {0:~ }| + {3:-- VISUAL --} | + ]]} + end + end) + + it("left drag changes visual selection in float window with winbar", function() + local buf = meths.create_buf(false,false) + meths.buf_set_lines(buf, 0, -1, true, {'foo', 'bar', 'baz'}) + local float_win = meths.open_win(buf, false, {relative='editor', width=20, height=4, row=1, col=5}) + meths.win_set_option(float_win, 'winbar', 'floaty bar') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + ## grid 5 + {3:floaty bar }| + {1:foo }| + {1:bar }| + {1:baz }| + ]], float_pos={ + [5] = {{id = 1002}, "NW", 1, 1, 5, true, 50}; + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3}; + }} + meths.input_mouse('left', 'press', '', 5, 1, 0) + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + ## grid 5 + {3:floaty bar }| + {1:^foo }| + {1:bar }| + {1:baz }| + ]], float_pos={ + [5] = {{id = 1002}, "NW", 1, 1, 5, true, 50}; + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3}; + }} + meths.input_mouse('left', 'drag', '', 5, 2, 2) + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + {3:-- VISUAL --} | + ## grid 5 + {3:floaty bar }| + {27:foo}{1: }| + {27:ba}{1:^r }| + {1:baz }| + ]], float_pos={ + [5] = {{id = 1002}, "NW", 1, 1, 5, true, 50}; + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 3}; + }} + else + screen:expect{grid=[[ + ^ | + {0:~ }{3:floaty bar }{0: }| + {0:~ }{1:foo }{0: }| + {0:~ }{1:bar }{0: }| + {0:~ }{1:baz }{0: }| + {0:~ }| + | + ]]} + + meths.input_mouse('left', 'press', '', 0, 2, 5) + screen:expect{grid=[[ + | + {0:~ }{3:floaty bar }{0: }| + {0:~ }{1:^foo }{0: }| + {0:~ }{1:bar }{0: }| + {0:~ }{1:baz }{0: }| + {0:~ }| + | + ]]} + + meths.input_mouse('left', 'drag', '', 0, 3, 7) + screen:expect{grid=[[ + | + {0:~ }{3:floaty bar }{0: }| + {0:~ }{27:foo}{1: }{0: }| + {0:~ }{27:ba}{1:^r }{0: }| + {0:~ }{1:baz }{0: }| {0:~ }| {3:-- VISUAL --} | ]]} @@ -7591,6 +7853,53 @@ describe('float window', function() ]]} end end) + + it('can use winbar', function() + local buf = meths.create_buf(false,false) + local win1 = meths.open_win(buf, false, {relative='editor', width=15, height=3, row=1, col=5}) + meths.win_set_option(win1, 'winbar', 'floaty bar') + + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + ## grid 4 + {3:floaty bar }| + {1: }| + {2:~ }| + ]], float_pos={ + [4] = {{id = 1001}, "NW", 1, 1, 5, true, 50}; + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + }} + else + screen:expect{grid=[[ + ^ | + {0:~ }{3:floaty bar }{0: }| + {0:~ }{1: }{0: }| + {0:~ }{2:~ }{0: }| + {0:~ }| + {0:~ }| + | + ]]} + end + end) end describe('with ext_multigrid', function() diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index 9762805dee..394f2f5f49 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -1757,6 +1757,67 @@ describe("folded lines", function() end assert_alive() end) + + it('work correctly with :move #18668', function() + screen:try_resize(45, 12) + source([[ + set foldmethod=expr foldexpr=indent(v:lnum) + let content = ['', '', 'Line1', ' Line2', ' Line3', + \ 'Line4', ' Line5', ' Line6', + \ 'Line7', ' Line8', ' Line9'] + call append(0, content) + normal! zM + call cursor(4, 1) + move 2 + move 1 + ]]) + if multigrid then + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + | + {5:^+-- 2 lines: Line2··························}| + | + Line1 | + Line4 | + {5:+-- 2 lines: Line5··························}| + Line7 | + {5:+-- 2 lines: Line8··························}| + | + {1:~ }| + {1:~ }| + ## grid 3 + | + ]]) + else + screen:expect([[ + | + {5:^+-- 2 lines: Line2··························}| + | + Line1 | + Line4 | + {5:+-- 2 lines: Line5··························}| + Line7 | + {5:+-- 2 lines: Line8··························}| + | + {1:~ }| + {1:~ }| + | + ]]) + end + end) end describe("with ext_multigrid", function() diff --git a/test/functional/ui/global_statusline_spec.lua b/test/functional/ui/global_statusline_spec.lua deleted file mode 100644 index 369c4a31f1..0000000000 --- a/test/functional/ui/global_statusline_spec.lua +++ /dev/null @@ -1,260 +0,0 @@ -local helpers = require('test.functional.helpers')(after_each) -local Screen = require('test.functional.ui.screen') -local clear, command, feed = helpers.clear, helpers.command, helpers.feed -local eq, funcs, meths = helpers.eq, helpers.funcs, helpers.meths - -describe('global statusline', function() - local screen - - before_each(function() - clear() - screen = Screen.new(60, 16) - screen:attach() - command('set laststatus=3') - command('set ruler') - end) - - it('works', function() - screen:expect{grid=[[ - ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {2:[No Name] 0,0-1 All}| - | - ]], attr_ids={ - [1] = {bold = true, foreground = Screen.colors.Blue1}; - [2] = {bold = true, reverse = true}; - }} - - feed('i<CR><CR>') - screen:expect{grid=[[ - | - | - ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {2:[No Name] [+] 3,1 All}| - {3:-- INSERT --} | - ]], attr_ids={ - [1] = {bold = true, foreground = Screen.colors.Blue}; - [2] = {bold = true, reverse = true}; - [3] = {bold = true}; - }} - end) - - it('works with splits', function() - command('vsplit | split | vsplit | vsplit | wincmd l | split | 2wincmd l | split') - screen:expect{grid=[[ - │ │ │^ | - {2:~ }│{2:~ }│{2:~}│{2:~ }| - {2:~ }│{2:~ }│{2:~}│{2:~ }| - {2:~ }│{2:~ }│{2:~}│{2:~ }| - {2:~ }├────────────────┤{2:~}│{2:~ }| - {2:~ }│ │{2:~}│{2:~ }| - {2:~ }│{2:~ }│{2:~}│{2:~ }| - {2:~ }│{2:~ }│{2:~}├────────────────────| - {2:~ }│{2:~ }│{2:~}│ | - ────────────────────┴────────────────┴─┤{2:~ }| - │{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {3:[No Name] 0,0-1 All}| - | - ]], attr_ids={ - [1] = {reverse = true}; - [2] = {bold = true, foreground = Screen.colors.Blue1}; - [3] = {bold = true, reverse = true}; - }} - end) - - it('works when switching between values of laststatus', function() - command('set laststatus=1') - screen:expect{grid=[[ - ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - 0,0-1 All | - ]], attr_ids={ - [1] = {foreground = Screen.colors.Blue, bold = true}; - }} - - command('set laststatus=3') - screen:expect{grid=[[ - ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {2:[No Name] 0,0-1 All}| - | - ]], attr_ids={ - [1] = {foreground = Screen.colors.Blue, bold = true}; - [2] = {reverse = true, bold = true}; - }} - - command('vsplit | split | vsplit | vsplit | wincmd l | split | 2wincmd l | split') - command('set laststatus=2') - screen:expect{grid=[[ - │ │ │^ | - {2:~ }│{2:~ }│{2:~}│{2:~ }| - {2:~ }│{2:~ }│{2:~}│{2:~ }| - {2:~ }│{2:~ }│{2:~}│{2:~ }| - {2:~ }│{1:< Name] 0,0-1 }│{2:~}│{2:~ }| - {2:~ }│ │{2:~}│{2:~ }| - {2:~ }│{2:~ }│{2:~}│{2:~ }| - {2:~ }│{2:~ }│{2:~}│{3:<No Name] 0,0-1 All}| - {2:~ }│{2:~ }│{2:~}│ | - {1:<No Name] 0,0-1 All < Name] 0,0-1 <}│{2:~ }| - │{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {1:[No Name] 0,0-1 All <No Name] 0,0-1 All}| - | - ]], attr_ids={ - [1] = {reverse = true}; - [2] = {foreground = Screen.colors.Blue, bold = true}; - [3] = {reverse = true, bold = true}; - }} - - command('set laststatus=3') - screen:expect{grid=[[ - │ │ │^ | - {2:~ }│{2:~ }│{2:~}│{2:~ }| - {2:~ }│{2:~ }│{2:~}│{2:~ }| - {2:~ }│{2:~ }│{2:~}│{2:~ }| - {2:~ }├────────────────┤{2:~}│{2:~ }| - {2:~ }│ │{2:~}│{2:~ }| - {2:~ }│{2:~ }│{2:~}│{2:~ }| - {2:~ }│{2:~ }│{2:~}├────────────────────| - {2:~ }│{2:~ }│{2:~}│ | - ────────────────────┴────────────────┴─┤{2:~ }| - │{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {3:[No Name] 0,0-1 All}| - | - ]], attr_ids={ - [1] = {reverse = true}; - [2] = {foreground = Screen.colors.Blue, bold = true}; - [3] = {reverse = true, bold = true}; - }} - - command('set laststatus=0') - screen:expect{grid=[[ - │ │ │^ | - {2:~ }│{2:~ }│{2:~}│{2:~ }| - {2:~ }│{2:~ }│{2:~}│{2:~ }| - {2:~ }│{2:~ }│{2:~}│{2:~ }| - {2:~ }│{1:< Name] 0,0-1 }│{2:~}│{2:~ }| - {2:~ }│ │{2:~}│{2:~ }| - {2:~ }│{2:~ }│{2:~}│{2:~ }| - {2:~ }│{2:~ }│{2:~}│{3:<No Name] 0,0-1 All}| - {2:~ }│{2:~ }│{2:~}│ | - {1:<No Name] 0,0-1 All < Name] 0,0-1 <}│{2:~ }| - │{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - 0,0-1 All | - ]], attr_ids={ - [1] = {reverse = true}; - [2] = {foreground = Screen.colors.Blue, bold = true}; - [3] = {reverse = true, bold = true}; - }} - - command('set laststatus=3') - screen:expect{grid=[[ - │ │ │^ | - {2:~ }│{2:~ }│{2:~}│{2:~ }| - {2:~ }│{2:~ }│{2:~}│{2:~ }| - {2:~ }│{2:~ }│{2:~}│{2:~ }| - {2:~ }├────────────────┤{2:~}│{2:~ }| - {2:~ }│ │{2:~}│{2:~ }| - {2:~ }│{2:~ }│{2:~}│{2:~ }| - {2:~ }│{2:~ }│{2:~}├────────────────────| - {2:~ }│{2:~ }│{2:~}│ | - ────────────────────┴────────────────┴─┤{2:~ }| - │{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {3:[No Name] 0,0-1 All}| - | - ]], attr_ids={ - [1] = {reverse = true}; - [2] = {foreground = Screen.colors.Blue, bold = true}; - [3] = {reverse = true, bold = true}; - }} - end) - - it('win_move_statusline() can reduce cmdheight to 1', function() - eq(1, meths.get_option('cmdheight')) - funcs.win_move_statusline(0, -1) - eq(2, meths.get_option('cmdheight')) - funcs.win_move_statusline(0, -1) - eq(3, meths.get_option('cmdheight')) - funcs.win_move_statusline(0, 1) - eq(2, meths.get_option('cmdheight')) - funcs.win_move_statusline(0, 1) - eq(1, meths.get_option('cmdheight')) - end) - - it('mouse dragging can reduce cmdheight to 1', function() - command('set mouse=a') - meths.input_mouse('left', 'press', '', 0, 14, 10) - eq(1, meths.get_option('cmdheight')) - meths.input_mouse('left', 'drag', '', 0, 13, 10) - eq(2, meths.get_option('cmdheight')) - meths.input_mouse('left', 'drag', '', 0, 12, 10) - eq(3, meths.get_option('cmdheight')) - meths.input_mouse('left', 'drag', '', 0, 13, 10) - eq(2, meths.get_option('cmdheight')) - meths.input_mouse('left', 'drag', '', 0, 14, 10) - eq(1, meths.get_option('cmdheight')) - end) -end) diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index 879c44773a..fb80444430 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -123,13 +123,11 @@ describe(":substitute, inccommand=split interactivity", function() it("no preview if invoked by feedkeys()", function() -- in a script... source([[:call feedkeys(":%s/tw/MO/g\<CR>")]]) - poke_eventloop() -- or interactively... - feed([[:call feedkeys(":%s/tw/MO/g\<CR>")<CR>]]) - poke_eventloop() + feed([[:call feedkeys(":%s/bs/BUU/g\<lt>CR>")<CR>]]) eq(1, eval("bufnr('$')")) -- sanity check: assert the buffer state - expect(default_text:gsub("tw", "MO")) + expect(default_text:gsub("tw", "MO"):gsub("bs", "BUU")) end) end) @@ -381,7 +379,7 @@ describe(":substitute, 'inccommand' preserves undo", function() } local function test_sub(substring, split, redoable) - clear() + command('bwipe!') feed_command("set inccommand=" .. split) insert("1") @@ -407,7 +405,7 @@ describe(":substitute, 'inccommand' preserves undo", function() end local function test_notsub(substring, split, redoable) - clear() + command('bwipe!') feed_command("set inccommand=" .. split) insert("1") @@ -441,7 +439,7 @@ describe(":substitute, 'inccommand' preserves undo", function() local function test_threetree(substring, split) - clear() + command('bwipe!') feed_command("set inccommand=" .. split) insert("1") @@ -493,6 +491,8 @@ describe(":substitute, 'inccommand' preserves undo", function() 2]]) end + before_each(clear) + it("at a non-leaf of the undo tree", function() for _, case in pairs(cases) do for _, str in pairs(substrings) do @@ -1646,10 +1646,12 @@ end) describe("'inccommand' and :cnoremap", function() local cases = { "", "split", "nosplit" } + local screen - local function refresh(case) + local function refresh(case, visual) clear() - common_setup(nil, case, default_text) + screen = visual and Screen.new(50,10) or nil + common_setup(screen, case, default_text) end it('work with remapped characters', function() @@ -1706,10 +1708,12 @@ describe("'inccommand' and :cnoremap", function() it('still works with a broken mapping', function() for _, case in pairs(cases) do - refresh(case) + refresh(case, true) feed_command("cnoremap <expr> x execute('bwipeout!')[-1].'x'") feed(":%s/tw/tox<enter>") + screen:expect{any=[[{14:^E523:]]} + feed('<c-c>') -- error thrown b/c of the mapping neq(nil, eval('v:errmsg'):find('^E523:')) diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index 041337df8a..ee49ae7a09 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -304,13 +304,25 @@ describe('ui/ext_messages', function() {1:~ }| {1:~ }| {1:~ }| - ]], messages={ + ]], msg_history={ {kind="echoerr", content={{"raa", 2}}}, {kind="echoerr", content={{"bork", 2}}}, {kind="echoerr", content={{"fail", 2}}}, {kind="echoerr", content={{"extrafail", 2}}}, {kind="echoerr", content={{"problem", 2}}} - }} + }, messages={{ + content = {{ "Press ENTER or type command to continue", 4 }}, + kind = "return_prompt" + }}} + + feed '<cr>' + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ]]} end) it('shortmess-=S', function() @@ -455,11 +467,14 @@ describe('ui/ext_messages', function() alphpabe^t | {1:~ }| {1:~ }| - ]], messages={ - {kind="echomsg", content={{"stuff"}}}, - }, showmode={ - { "-- INSERT --", 3 } - }} + ]], msg_history={{ + content = {{ "stuff" }}, + kind = "echomsg", + }}, showmode={{ "-- INSERT --", 3 }}, + messages={{ + content = {{ "Press ENTER or type command to continue", 4}}, + kind = "return_prompt" + }}} end) it('&showmode with macro-recording message', function() @@ -685,12 +700,15 @@ describe('ui/ext_messages', function() {1:~ }| {1:~ }| {1:~ }| - ]], messages={ + ]], msg_history={ {kind="echomsg", content={{"howdy"}}}, {kind="", content={{"Type :qa and press <Enter> to exit Nvim"}}}, {kind="echoerr", content={{"bork", 2}}}, {kind="emsg", content={{"E117: Unknown function: nosuchfunction", 2}}} - }} + }, messages={{ + content = {{ "Press ENTER or type command to continue", 4}}, + kind = "return_prompt" + }}} end) it('implies ext_cmdline and ignores cmdheight', function() @@ -1209,7 +1227,6 @@ describe('ui/ext_messages', function() it('supports global statusline', function() feed(":set laststatus=3<cr>") feed(":sp<cr>") - feed("<c-l>") feed(":set cmdheight<cr>") screen:expect({grid=[[ ^ | @@ -1241,8 +1258,7 @@ describe('ui/ext_messages', function() }}) feed("<c-w>+") - feed("<c-l>") - feed(":set cmdheight<cr>") + feed(":set laststatus<cr>") screen:expect({grid=[[ ^ | {1:~ }| @@ -1269,7 +1285,7 @@ describe('ui/ext_messages', function() {1:~ }| {7:[No Name] }| ]], messages={ - {content = { { " cmdheight=0" } }, kind = "" } + {content = { { " laststatus=3" } }, kind = "" } }}) feed(":set mouse=a<cr>") @@ -1312,7 +1328,6 @@ end) describe('ui/msg_puts_printf', function() it('output multibyte characters correctly', function() - if helpers.pending_win32(pending) then return end local screen local cmd = '' local locale_dir = test_build_dir..'/share/locale/ja/LC_MESSAGES' diff --git a/test/functional/ui/multigrid_spec.lua b/test/functional/ui/multigrid_spec.lua index 20e8821009..b30aa67fd3 100644 --- a/test/functional/ui/multigrid_spec.lua +++ b/test/functional/ui/multigrid_spec.lua @@ -1915,7 +1915,7 @@ describe('ext_multigrid', function() {1:~ }| ]]} - meths.input_mouse('left', 'press', '', 1,6, 20) + meths.input_mouse('left', 'press', '', 1, 6, 20) -- TODO(bfredl): "batching" input_mouse is formally not supported yet. -- Normally it should work fine in async context when nvim is not blocked, -- but add a poke_eventloop be sure. @@ -2092,7 +2092,6 @@ describe('ext_multigrid', function() {1:~ }| {1:~ }| ]]} - end) it('has viewport information', function() @@ -2369,4 +2368,223 @@ describe('ext_multigrid', function() [2] = {win = {id = 1000}, topline = 6, botline = 12, curline = 10, curcol = 1, linecount = 11}, }} end) + + it('with winbar', function() + command 'split' + command 'setlocal winbar=very\\ bar' + screen:expect{grid=[[ + ## grid 1 + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + {11:[No Name] }| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + {12:[No Name] }| + [3:-----------------------------------------------------]| + ## grid 2 + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + | + ## grid 4 + {7:very bar }| + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + }} + end) + + it('with winbar dragging statusline with mouse works correctly', function() + meths.set_option('winbar', 'Set Up The Bars') + command('split') + screen:expect([[ + ## grid 1 + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + {11:[No Name] }| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + {12:[No Name] }| + [3:-----------------------------------------------------]| + ## grid 2 + {7:Set Up The Bars }| + | + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + | + ## grid 4 + {7:Set Up The Bars }| + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ]]) + + meths.input_mouse('left', 'press', '', 1, 6, 20) + poke_eventloop() + meths.input_mouse('left', 'drag', '', 1, 7, 20) + screen:expect([[ + ## grid 1 + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + {11:[No Name] }| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + {12:[No Name] }| + [3:-----------------------------------------------------]| + ## grid 2 + {7:Set Up The Bars }| + | + {1:~ }| + {1:~ }| + ## grid 3 + | + ## grid 4 + {7:Set Up The Bars }| + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ]]) + + meths.input_mouse('left', 'drag', '', 1, 4, 20) + screen:expect([[ + ## grid 1 + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + {11:[No Name] }| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + {12:[No Name] }| + [3:-----------------------------------------------------]| + ## grid 2 + {7:Set Up The Bars }| + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + | + ## grid 4 + {7:Set Up The Bars }| + ^ | + {1:~ }| + {1:~ }| + ]]) + + meths.input_mouse('left', 'press', '', 1, 12, 10) + poke_eventloop() + meths.input_mouse('left', 'drag', '', 1, 10, 10) + screen:expect([[ + ## grid 1 + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + {11:[No Name] }| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + {12:[No Name] }| + [3:-----------------------------------------------------]| + [3:-----------------------------------------------------]| + [3:-----------------------------------------------------]| + ## grid 2 + {7:Set Up The Bars }| + | + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + | + | + | + ## grid 4 + {7:Set Up The Bars }| + ^ | + {1:~ }| + {1:~ }| + ]]) + eq(3, meths.get_option('cmdheight')) + + meths.input_mouse('left', 'drag', '', 1, 12, 10) + screen:expect([[ + ## grid 1 + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + {11:[No Name] }| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + {12:[No Name] }| + [3:-----------------------------------------------------]| + ## grid 2 + {7:Set Up The Bars }| + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + | + ## grid 4 + {7:Set Up The Bars }| + ^ | + {1:~ }| + {1:~ }| + ]]) + eq(1, meths.get_option('cmdheight')) + end) end) diff --git a/test/functional/ui/output_spec.lua b/test/functional/ui/output_spec.lua index 7305baa761..50e5dfac84 100644 --- a/test/functional/ui/output_spec.lua +++ b/test/functional/ui/output_spec.lua @@ -14,7 +14,6 @@ local has_powershell = helpers.has_powershell local set_shell_powershell = helpers.set_shell_powershell describe("shell command :!", function() - if helpers.pending_win32(pending) then return end local screen before_each(function() clear() diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index 06daabad1a..d6de1fa8a9 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -242,7 +242,7 @@ end -- canonical order of ext keys, used to generate asserts local ext_keys = { 'popupmenu', 'cmdline', 'cmdline_block', 'wildmenu_items', 'wildmenu_pos', - 'messages', 'showmode', 'showcmd', 'ruler', 'float_pos', 'win_viewport' + 'messages', 'msg_history', 'showmode', 'showcmd', 'ruler', 'float_pos', 'win_viewport' } -- Asserts that the screen state eventually matches an expected state. @@ -1083,6 +1083,10 @@ function Screen:_handle_msg_history_show(entries) self.msg_history = entries end +function Screen:_handle_msg_history_clear() + self.msg_history = {} +end + function Screen:_clear_block(grid, top, bot, left, right) for i = top, bot do self:_clear_row_section(grid, i, left, right) @@ -1171,7 +1175,7 @@ function Screen:_extstate_repr(attr_state) local msg_history = {} for i, entry in ipairs(self.msg_history) do - messages[i] = {kind=entry[1], content=self:_chunks_repr(entry[2], attr_state)} + msg_history[i] = {kind=entry[1], content=self:_chunks_repr(entry[2], attr_state)} end local win_viewport = (next(self.win_viewport) and self.win_viewport) or nil diff --git a/test/functional/ui/searchhl_spec.lua b/test/functional/ui/searchhl_spec.lua index 56ff8a4101..cdb6256f77 100644 --- a/test/functional/ui/searchhl_spec.lua +++ b/test/functional/ui/searchhl_spec.lua @@ -43,7 +43,7 @@ describe('search highlighting', function() insert("some text\nmore text") feed_command('1,2fold') feed("gg/text") - screen:expect([[ + screen:expect{grid=[[ {6:+-- 2 lines: some text·················}| {1:~ }| {1:~ }| @@ -51,7 +51,9 @@ describe('search highlighting', function() {1:~ }| {1:~ }| /text^ | - ]]) + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 3, curline = 0, curcol = 9, linecount = 2}; + }} end) it('works', function() @@ -579,19 +581,20 @@ describe('search highlighting', function() end) it('works with matchadd and syntax', function() - screen:set_default_attr_ids( { - [1] = {bold=true, foreground=Screen.colors.Blue}, - [2] = {background = colors.Yellow}, - [3] = {reverse = true}, - [4] = {foreground = colors.Red}, - [5] = {bold = true, background = colors.Green}, - [6] = {italic = true, background = colors.Magenta}, - [7] = {bold = true, background = colors.Yellow}, - } ) + screen:set_default_attr_ids { + [1] = {bold=true, foreground=Screen.colors.Blue}; + [2] = {background = colors.Yellow}; + [3] = {reverse = true}; + [4] = {foreground = colors.Red}; + [5] = {bold = true, background = colors.Green}; + [6] = {italic = true, background = colors.Magenta}; + [7] = {bold = true, background = colors.Yellow}; + [8] = {foreground = Screen.colors.Blue4, background = Screen.colors.LightGray}; + } feed_command('set hlsearch') - insert([[ + insert [[ very special text - ]]) + ]] feed_command("syntax on") feed_command("highlight MyGroup guibg=Green gui=bold") feed_command("highlight MyGroup2 guibg=Magenta gui=italic") @@ -601,7 +604,7 @@ describe('search highlighting', function() -- searchhl and matchadd matches are exclusive, only the highest priority -- is used (and matches with lower priorities are not combined) feed_command("/ial te") - screen:expect([[ + screen:expect{grid=[[ very {5:spec^ial}{2: te}{6:xt} | | {1:~ }| @@ -609,10 +612,21 @@ describe('search highlighting', function() {1:~ }| {1:~ }| {4:search hit BOTTOM, continuing at TOP} | - ]]) + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 3, curline = 0, curcol = 11, linecount = 2}; + }} -- check highlights work also in folds feed("zf4j") + screen:expect{grid=[[ + {8:^+-- 2 lines: very special text·········}| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {4:search hit BOTTOM, continuing at TOP} | + ]]} command("%foldopen") screen:expect([[ very {5:spec^ial}{2: te}{6:xt} | diff --git a/test/functional/ui/statusline_spec.lua b/test/functional/ui/statusline_spec.lua new file mode 100644 index 0000000000..3e1b284856 --- /dev/null +++ b/test/functional/ui/statusline_spec.lua @@ -0,0 +1,317 @@ +local helpers = require('test.functional.helpers')(after_each) +local Screen = require('test.functional.ui.screen') +local clear = helpers.clear +local command = helpers.command +local feed = helpers.feed +local eq = helpers.eq +local funcs = helpers.funcs +local meths = helpers.meths +local exec = helpers.exec +local exec_lua = helpers.exec_lua +local eval = helpers.eval + +describe('statusline clicks', function() + local screen + + before_each(function() + clear() + screen = Screen.new(40, 8) + screen:attach() + command('set laststatus=2') + exec([=[ + function! MyClickFunc(minwid, clicks, button, mods) + let g:testvar = printf("%d %d %s", a:minwid, a:clicks, a:button) + endfunction + ]=]) + end) + + it('works', function() + meths.set_option('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T') + meths.input_mouse('left', 'press', '', 0, 6, 17) + eq('0 1 l', eval("g:testvar")) + meths.input_mouse('right', 'press', '', 0, 6, 17) + eq('0 1 r', eval("g:testvar")) + end) + + it('works for winbar', function() + meths.set_option('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T') + meths.input_mouse('left', 'press', '', 0, 0, 17) + eq('0 1 l', eval("g:testvar")) + meths.input_mouse('right', 'press', '', 0, 6, 17) + eq('0 1 r', eval("g:testvar")) + end) + + it('works for winbar in floating window', function() + meths.open_win(0, true, { width=30, height=4, relative='editor', row=1, col=5, + border = "single" }) + meths.set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', + { scope = 'local' }) + meths.input_mouse('left', 'press', '', 0, 2, 23) + eq('0 1 l', eval("g:testvar")) + end) + + it('works when there are multiple windows', function() + command('split') + meths.set_option('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T') + meths.set_option('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T') + meths.input_mouse('left', 'press', '', 0, 0, 17) + eq('0 1 l', eval("g:testvar")) + meths.input_mouse('right', 'press', '', 0, 4, 17) + eq('0 1 r', eval("g:testvar")) + meths.input_mouse('middle', 'press', '', 0, 3, 17) + eq('0 1 m', eval("g:testvar")) + meths.input_mouse('left', 'press', '', 0, 6, 17) + eq('0 1 l', eval("g:testvar")) + end) + + it('works with Lua function', function() + exec_lua([[ + function clicky_func(minwid, clicks, button, mods) + vim.g.testvar = string.format("%d %d %s", minwid, clicks, button) + end + ]]) + meths.set_option('statusline', 'Not clicky stuff %0@v:lua.clicky_func@Clicky stuff%T') + meths.input_mouse('left', 'press', '', 0, 6, 17) + eq('0 1 l', eval("g:testvar")) + end) + + it('ignores unsupported click items', function() + command('tabnew | tabprevious') + meths.set_option('statusline', '%2TNot clicky stuff%T') + meths.input_mouse('left', 'press', '', 0, 6, 0) + eq(1, meths.get_current_tabpage().id) + meths.set_option('statusline', '%2XNot clicky stuff%X') + meths.input_mouse('left', 'press', '', 0, 6, 0) + eq(2, #meths.list_tabpages()) + end) +end) + +describe('global statusline', function() + local screen + + before_each(function() + clear() + screen = Screen.new(60, 16) + screen:attach() + screen:set_default_attr_ids({ + [1] = {bold = true, foreground = Screen.colors.Blue}; + [2] = {bold = true, reverse = true}; + [3] = {bold = true}; + [4] = {reverse = true}; + }) + command('set laststatus=3') + command('set ruler') + end) + + it('works', function() + screen:expect([[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {2:[No Name] 0,0-1 All}| + | + ]]) + + feed('i<CR><CR>') + screen:expect([[ + | + | + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {2:[No Name] [+] 3,1 All}| + {3:-- INSERT --} | + ]]) + end) + + it('works with splits', function() + command('vsplit | split | vsplit | vsplit | wincmd l | split | 2wincmd l | split') + screen:expect([[ + │ │ │^ | + {1:~ }│{1:~ }│{1:~}│{1:~ }| + {1:~ }│{1:~ }│{1:~}│{1:~ }| + {1:~ }│{1:~ }│{1:~}│{1:~ }| + {1:~ }├────────────────┤{1:~}│{1:~ }| + {1:~ }│ │{1:~}│{1:~ }| + {1:~ }│{1:~ }│{1:~}│{1:~ }| + {1:~ }│{1:~ }│{1:~}├────────────────────| + {1:~ }│{1:~ }│{1:~}│ | + ────────────────────┴────────────────┴─┤{1:~ }| + │{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {2:[No Name] 0,0-1 All}| + | + ]]) + end) + + it('works when switching between values of laststatus', function() + command('set laststatus=1') + screen:expect([[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + 0,0-1 All | + ]]) + + command('set laststatus=3') + screen:expect([[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {2:[No Name] 0,0-1 All}| + | + ]]) + + command('vsplit | split | vsplit | vsplit | wincmd l | split | 2wincmd l | split') + command('set laststatus=2') + screen:expect([[ + │ │ │^ | + {1:~ }│{1:~ }│{1:~}│{1:~ }| + {1:~ }│{1:~ }│{1:~}│{1:~ }| + {1:~ }│{1:~ }│{1:~}│{1:~ }| + {1:~ }│{4:< Name] 0,0-1 }│{1:~}│{1:~ }| + {1:~ }│ │{1:~}│{1:~ }| + {1:~ }│{1:~ }│{1:~}│{1:~ }| + {1:~ }│{1:~ }│{1:~}│{2:<No Name] 0,0-1 All}| + {1:~ }│{1:~ }│{1:~}│ | + {4:<No Name] 0,0-1 All < Name] 0,0-1 <}│{1:~ }| + │{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {4:[No Name] 0,0-1 All <No Name] 0,0-1 All}| + | + ]]) + + command('set laststatus=3') + screen:expect([[ + │ │ │^ | + {1:~ }│{1:~ }│{1:~}│{1:~ }| + {1:~ }│{1:~ }│{1:~}│{1:~ }| + {1:~ }│{1:~ }│{1:~}│{1:~ }| + {1:~ }├────────────────┤{1:~}│{1:~ }| + {1:~ }│ │{1:~}│{1:~ }| + {1:~ }│{1:~ }│{1:~}│{1:~ }| + {1:~ }│{1:~ }│{1:~}├────────────────────| + {1:~ }│{1:~ }│{1:~}│ | + ────────────────────┴────────────────┴─┤{1:~ }| + │{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {2:[No Name] 0,0-1 All}| + | + ]]) + + command('set laststatus=0') + screen:expect([[ + │ │ │^ | + {1:~ }│{1:~ }│{1:~}│{1:~ }| + {1:~ }│{1:~ }│{1:~}│{1:~ }| + {1:~ }│{1:~ }│{1:~}│{1:~ }| + {1:~ }│{4:< Name] 0,0-1 }│{1:~}│{1:~ }| + {1:~ }│ │{1:~}│{1:~ }| + {1:~ }│{1:~ }│{1:~}│{1:~ }| + {1:~ }│{1:~ }│{1:~}│{2:<No Name] 0,0-1 All}| + {1:~ }│{1:~ }│{1:~}│ | + {4:<No Name] 0,0-1 All < Name] 0,0-1 <}│{1:~ }| + │{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + 0,0-1 All | + ]]) + + command('set laststatus=3') + screen:expect([[ + │ │ │^ | + {1:~ }│{1:~ }│{1:~}│{1:~ }| + {1:~ }│{1:~ }│{1:~}│{1:~ }| + {1:~ }│{1:~ }│{1:~}│{1:~ }| + {1:~ }├────────────────┤{1:~}│{1:~ }| + {1:~ }│ │{1:~}│{1:~ }| + {1:~ }│{1:~ }│{1:~}│{1:~ }| + {1:~ }│{1:~ }│{1:~}├────────────────────| + {1:~ }│{1:~ }│{1:~}│ | + ────────────────────┴────────────────┴─┤{1:~ }| + │{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {2:[No Name] 0,0-1 All}| + | + ]]) + end) + + it('win_move_statusline() can reduce cmdheight to 1', function() + eq(1, meths.get_option('cmdheight')) + funcs.win_move_statusline(0, -1) + eq(2, meths.get_option('cmdheight')) + funcs.win_move_statusline(0, -1) + eq(3, meths.get_option('cmdheight')) + funcs.win_move_statusline(0, 1) + eq(2, meths.get_option('cmdheight')) + funcs.win_move_statusline(0, 1) + eq(1, meths.get_option('cmdheight')) + end) + + it('mouse dragging can reduce cmdheight to 1', function() + command('set mouse=a') + meths.input_mouse('left', 'press', '', 0, 14, 10) + eq(1, meths.get_option('cmdheight')) + meths.input_mouse('left', 'drag', '', 0, 13, 10) + eq(2, meths.get_option('cmdheight')) + meths.input_mouse('left', 'drag', '', 0, 12, 10) + eq(3, meths.get_option('cmdheight')) + meths.input_mouse('left', 'drag', '', 0, 13, 10) + eq(2, meths.get_option('cmdheight')) + meths.input_mouse('left', 'drag', '', 0, 14, 10) + eq(1, meths.get_option('cmdheight')) + end) +end) diff --git a/test/functional/ui/winbar_spec.lua b/test/functional/ui/winbar_spec.lua new file mode 100644 index 0000000000..83bc61bc4e --- /dev/null +++ b/test/functional/ui/winbar_spec.lua @@ -0,0 +1,422 @@ +local helpers = require('test.functional.helpers')(after_each) +local Screen = require('test.functional.ui.screen') +local clear = helpers.clear +local command = helpers.command +local insert = helpers.insert +local meths = helpers.meths +local eq = helpers.eq +local poke_eventloop = helpers.poke_eventloop +local feed = helpers.feed + +describe('winbar', function() + local screen + + before_each(function() + clear() + screen = Screen.new(60, 13) + screen:attach() + screen:set_default_attr_ids({ + [1] = {bold = true}, + [2] = {reverse = true}, + [3] = {bold = true, foreground = Screen.colors.Blue}, + [4] = {bold = true, reverse = true}, + [5] = {bold = true, foreground = Screen.colors.Red}, + [6] = {foreground = Screen.colors.Blue}, + [7] = {background = Screen.colors.LightGrey}, + }) + meths.set_option('winbar', 'Set Up The Bars') + end) + it('works', function() + screen:expect([[ + {1:Set Up The Bars }| + ^ | + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + | + ]]) + end) + it('works with custom \'fillchars\' value', function() + command('set fillchars=wbr:+') + screen:expect([[ + {1:Set Up The Bars+++++++++++++++++++++++++++++++++++++++++++++}| + ^ | + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + | + ]]) + end) + it('works with custom highlight', function() + command('hi WinBar guifg=red') + screen:expect([[ + {5:Set Up The Bars }| + ^ | + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + | + ]]) + end) + it('works with splits', function() + command('hi WinBar guifg=red') + command('hi WinBarNC guifg=blue') + command('belowright vsplit | split | split') + screen:expect([[ + {6:Set Up The Bars }│{5:Set Up The Bars }| + │^ | + {3:~ }│{3:~ }| + {3:~ }│{4:[No Name] }| + {3:~ }│{6:Set Up The Bars }| + {3:~ }│ | + {3:~ }│{3:~ }| + {3:~ }│{2:[No Name] }| + {3:~ }│{6:Set Up The Bars }| + {3:~ }│ | + {3:~ }│{3:~ }| + {2:[No Name] [No Name] }| + | + ]]) + end) + it('works when switching value of \'winbar\'', function() + command('belowright vsplit | split | split | set winbar=') + screen:expect([[ + │^ | + {3:~ }│{3:~ }| + {3:~ }│{3:~ }| + {3:~ }│{4:[No Name] }| + {3:~ }│ | + {3:~ }│{3:~ }| + {3:~ }│{3:~ }| + {3:~ }│{2:[No Name] }| + {3:~ }│ | + {3:~ }│{3:~ }| + {3:~ }│{3:~ }| + {2:[No Name] [No Name] }| + | + ]]) + command('set winbar=All\\ Your\\ Bar\\ Are\\ Belong\\ To\\ Us') + screen:expect([[ + {1:All Your Bar Are Belong To Us}│{1:All Your Bar Are Belong To Us }| + │^ | + {3:~ }│{3:~ }| + {3:~ }│{4:[No Name] }| + {3:~ }│{1:All Your Bar Are Belong To Us }| + {3:~ }│ | + {3:~ }│{3:~ }| + {3:~ }│{2:[No Name] }| + {3:~ }│{1:All Your Bar Are Belong To Us }| + {3:~ }│ | + {3:~ }│{3:~ }| + {2:[No Name] [No Name] }| + | + ]]) + command('set winbar=Changed\\ winbar') + screen:expect([[ + {1:Changed winbar }│{1:Changed winbar }| + │^ | + {3:~ }│{3:~ }| + {3:~ }│{4:[No Name] }| + {3:~ }│{1:Changed winbar }| + {3:~ }│ | + {3:~ }│{3:~ }| + {3:~ }│{2:[No Name] }| + {3:~ }│{1:Changed winbar }| + {3:~ }│ | + {3:~ }│{3:~ }| + {2:[No Name] [No Name] }| + | + ]]) + end) + it('can be ruler', function() + insert [[ + just some + random text]] + meths.set_option('winbar', 'Hello, I am a ruler: %l,%c') + screen:expect{grid=[[ + {1:Hello, I am a ruler: 2,11 }| + just some | + random tex^t | + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + | + ]]} + feed 'b' + screen:expect{grid=[[ + {1:Hello, I am a ruler: 2,8 }| + just some | + random ^text | + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + | + ]]} + feed 'k' + screen:expect{grid=[[ + {1:Hello, I am a ruler: 1,8 }| + just so^me | + random text | + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + | + ]]} + end) + it('works with laststatus=3', function() + command('set laststatus=3') + screen:expect([[ + {1:Set Up The Bars }| + ^ | + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {4:[No Name] }| + | + ]]) + command('belowright vsplit | split | split') + screen:expect([[ + {1:Set Up The Bars }│{1:Set Up The Bars }| + │^ | + {3:~ }│{3:~ }| + {3:~ }├──────────────────────────────| + {3:~ }│{1:Set Up The Bars }| + {3:~ }│ | + {3:~ }│{3:~ }| + {3:~ }├──────────────────────────────| + {3:~ }│{1:Set Up The Bars }| + {3:~ }│ | + {3:~ }│{3:~ }| + {4:[No Name] }| + | + ]]) + end) + + it('mouse click and drag work correctly in buffer', function() + insert([[ + line 1 + line 2 + line 3 + line 4 + line -42 + line i + line sin(theta) + line 8]]) + + meths.input_mouse('left', 'press', '', 0, 5, 1) + screen:expect([[ + {1:Set Up The Bars }| + line 1 | + line 2 | + line 3 | + line 4 | + l^ine -42 | + line i | + line sin(theta) | + line 8 | + {3:~ }| + {3:~ }| + {3:~ }| + | + ]]) + eq({5, 1}, meths.win_get_cursor(0)) + + meths.input_mouse('left', 'drag', '', 0, 6, 2) + screen:expect([[ + {1:Set Up The Bars }| + line 1 | + line 2 | + line 3 | + line 4 | + l{7:ine -42} | + {7:li}^ne i | + line sin(theta) | + line 8 | + {3:~ }| + {3:~ }| + {3:~ }| + {1:-- VISUAL --} | + ]]) + eq({6, 2}, meths.win_get_cursor(0)) + + meths.input_mouse('left', 'drag', '', 0, 1, 2) + screen:expect([[ + {1:Set Up The Bars }| + li^n{7:e 1} | + {7:line 2} | + {7:line 3} | + {7:line 4} | + {7:li}ne -42 | + line i | + line sin(theta) | + line 8 | + {3:~ }| + {3:~ }| + {3:~ }| + {1:-- VISUAL --} | + ]]) + eq({1, 2}, meths.win_get_cursor(0)) + + meths.input_mouse('left', 'drag', '', 0, 0, 2) + screen:expect_unchanged() + eq({1, 2}, meths.win_get_cursor(0)) + end) + + it('dragging statusline with mouse works correctly', function() + command('split') + screen:expect([[ + {1:Set Up The Bars }| + ^ | + {3:~ }| + {3:~ }| + {3:~ }| + {4:[No Name] }| + {1:Set Up The Bars }| + | + {3:~ }| + {3:~ }| + {3:~ }| + {2:[No Name] }| + | + ]]) + + meths.input_mouse('left', 'press', '', 1, 5, 10) + poke_eventloop() + meths.input_mouse('left', 'drag', '', 1, 6, 10) + screen:expect([[ + {1:Set Up The Bars }| + ^ | + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {4:[No Name] }| + {1:Set Up The Bars }| + | + {3:~ }| + {3:~ }| + {2:[No Name] }| + | + ]]) + + meths.input_mouse('left', 'drag', '', 1, 4, 10) + screen:expect([[ + {1:Set Up The Bars }| + ^ | + {3:~ }| + {3:~ }| + {4:[No Name] }| + {1:Set Up The Bars }| + | + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {2:[No Name] }| + | + ]]) + + meths.input_mouse('left', 'press', '', 1, 11, 10) + poke_eventloop() + meths.input_mouse('left', 'drag', '', 1, 9, 10) + screen:expect([[ + {1:Set Up The Bars }| + ^ | + {3:~ }| + {3:~ }| + {4:[No Name] }| + {1:Set Up The Bars }| + | + {3:~ }| + {3:~ }| + {2:[No Name] }| + | + | + | + ]]) + eq(3, meths.get_option('cmdheight')) + + meths.input_mouse('left', 'drag', '', 1, 11, 10) + screen:expect([[ + {1:Set Up The Bars }| + ^ | + {3:~ }| + {3:~ }| + {4:[No Name] }| + {1:Set Up The Bars }| + | + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {2:[No Name] }| + | + ]]) + eq(1, meths.get_option('cmdheight')) + end) + it('properly equalizes window height for window-local value', function() + command('set equalalways | set winbar= | setlocal winbar=a | split') + command('setlocal winbar= | split') + command('setlocal winbar=b | split') + screen:expect([[ + {1:b }| + ^ | + {4:[No Name] }| + {1:b }| + | + {2:[No Name] }| + | + {3:~ }| + {2:[No Name] }| + {1:a }| + | + {2:[No Name] }| + | + ]]) + end) +end) diff --git a/test/functional/vimscript/execute_spec.lua b/test/functional/vimscript/execute_spec.lua index e21c71dc7f..a733b098f5 100644 --- a/test/functional/vimscript/execute_spec.lua +++ b/test/functional/vimscript/execute_spec.lua @@ -153,7 +153,7 @@ describe('execute()', function() function! Test3() echo 1234 let x = execute('echoerr "abcdef"', 'silent!') - echon 'ABCD' + echon 'ABCDXZYZ' endfunction " test 4: silenced echoerr goes as usual @@ -214,7 +214,7 @@ describe('execute()', function() ~ | ~ | ~ | - 1234ABCD | + 1234ABCDXZYZ | ]]) feed([[:call Test4()<cr>]]) |