diff options
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/api/vim_spec.lua | 76 | ||||
-rw-r--r-- | test/functional/fixtures/fake-lsp-server.lua | 42 | ||||
-rw-r--r-- | test/functional/plugin/lsp_spec.lua | 79 | ||||
-rw-r--r-- | test/functional/ui/messages_spec.lua | 106 |
4 files changed, 236 insertions, 67 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 7e54ae0248..610036f484 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -3104,9 +3104,7 @@ describe('API', function() cmd = 'echo', args = { 'foo' }, bang = false, - line1 = -1, - line2 = -1, - range = 0, + range = {}, count = -1, reg = '', addr = 'none', @@ -3142,9 +3140,7 @@ describe('API', function() cmd = 'substitute', args = { '/math.random/math.max/' }, bang = false, - line1 = 4, - line2 = 6, - range = 2, + range = { 4, 6 }, count = -1, reg = '', addr = 'line', @@ -3180,9 +3176,7 @@ describe('API', function() cmd = 'buffer', args = {}, bang = false, - line1 = 1, - line2 = 1, - range = 1, + range = {}, count = 1, reg = '', addr = 'buf', @@ -3218,9 +3212,7 @@ describe('API', function() cmd = 'put', args = {}, bang = false, - line1 = 1, - line2 = 1, - range = 0, + range = {}, count = -1, reg = '+', addr = 'line', @@ -3256,9 +3248,7 @@ describe('API', function() cmd = 'write', args = {}, bang = true, - line1 = 1, - line2 = 1, - range = 0, + range = {}, count = -1, reg = '', addr = 'line', @@ -3294,9 +3284,7 @@ describe('API', function() cmd = 'split', args = { 'foo.txt' }, bang = false, - line1 = 1, - line2 = 1, - range = 0, + range = {}, count = -1, reg = '', addr = '?', @@ -3333,9 +3321,7 @@ describe('API', function() cmd = 'MyCommand', args = { 'test', 'it' }, bang = true, - line1 = 4, - line2 = 6, - range = 2, + range = { 4, 6 }, count = -1, reg = '', addr = 'line', @@ -3371,9 +3357,7 @@ describe('API', function() cmd = 'argadd', args = { 'a.txt' }, bang = false, - line1 = 0, - line2 = 0, - range = 0, + range = {}, count = -1, reg = '', addr = 'arg', @@ -3410,9 +3394,7 @@ describe('API', function() cmd = 'MyCommand', args = { 'test it' }, bang = false, - line1 = -1, - line2 = -1, - range = 0, + range = {}, count = -1, reg = '', addr = 'none', @@ -3443,46 +3425,6 @@ describe('API', function() } }, meths.parse_cmd('MyCommand test it', {})) end) - it('sets correct default range', function() - command('command -range=% -addr=buffers MyCommand echo foo') - command('new') - eq({ - cmd = 'MyCommand', - args = {}, - bang = false, - line1 = 1, - line2 = 2, - range = 0, - count = -1, - reg = '', - addr = 'buf', - magic = { - file = false, - bar = false - }, - nargs = '0', - nextcmd = '', - mods = { - browse = false, - confirm = false, - emsg_silent = false, - hide = false, - keepalt = false, - keepjumps = false, - keepmarks = false, - keeppatterns = false, - lockmarks = false, - noautocmd = false, - noswapfile = false, - sandbox = false, - silent = false, - vertical = false, - split = "", - tab = 0, - verbose = -1 - } - }, meths.parse_cmd('MyCommand', {})) - end) it('errors for invalid command', function() eq('Error while parsing command line', pcall_err(meths.parse_cmd, 'Fubar', {})) command('command! Fubar echo foo') diff --git a/test/functional/fixtures/fake-lsp-server.lua b/test/functional/fixtures/fake-lsp-server.lua index 79a29cd8d8..0418ca7335 100644 --- a/test/functional/fixtures/fake-lsp-server.lua +++ b/test/functional/fixtures/fake-lsp-server.lua @@ -792,6 +792,48 @@ function tests.clientside_commands() } end +function tests.codelens_refresh_lock() + skeleton { + on_init = function() + return { + capabilities = { + codeLensProvider = { resolveProvider = true; }; + } + } + end; + body = function() + notify('start') + expect_request("textDocument/codeLens", function () + return {code = -32002, message = "ServerNotInitialized"}, nil + end) + expect_request("textDocument/codeLens", function () + local lenses = { + { + range = { + start = { line = 0, character = 0, }, + ['end'] = { line = 0, character = 3 } + }, + command = { title = 'Lens1', command = 'Dummy' } + }, + } + return nil, lenses + end) + expect_request("textDocument/codeLens", function () + local lenses = { + { + range = { + start = { line = 0, character = 0, }, + ['end'] = { line = 0, character = 3 } + }, + command = { title = 'Lens2', command = 'Dummy' } + }, + } + return nil, lenses + end) + notify('shutdown') + end; + } +end function tests.basic_formatting() skeleton { diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua index 3ee293db66..530d414334 100644 --- a/test/functional/plugin/lsp_spec.lua +++ b/test/functional/plugin/lsp_spec.lua @@ -2833,6 +2833,85 @@ describe('LSP', function() end } end) + + it('releases buffer refresh lock', function() + local client + local expected_handlers = { + {NIL, {}, {method="shutdown", client_id=1}}; + {NIL, {}, {method="start", client_id=1}}; + } + test_rpc_server { + test_name = 'codelens_refresh_lock', + on_init = function(client_) + client = client_ + end, + on_setup = function() + exec_lua([=[ + local bufnr = vim.api.nvim_get_current_buf() + vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, {'One line'}) + vim.lsp.buf_attach_client(bufnr, TEST_RPC_CLIENT_ID) + + CALLED = false + RESPONSE = nil + local on_codelens = vim.lsp.codelens.on_codelens + vim.lsp.codelens.on_codelens = function (err, result, ...) + CALLED = true + RESPONSE = { err = err, result = result } + return on_codelens(err, result, ...) + end + ]=]) + end, + on_exit = function(code, signal) + eq(0, code, "exit code", fake_lsp_logfile) + eq(0, signal, "exit signal", fake_lsp_logfile) + end, + on_handler = function(err, result, ctx) + eq(table.remove(expected_handlers), {err, result, ctx}) + if ctx.method == 'start' then + -- 1. first codelens request errors + local response = exec_lua([=[ + CALLED = false + vim.lsp.codelens.refresh() + vim.wait(100, function () return CALLED end) + return RESPONSE + ]=]) + eq( { err = { code = -32002, message = "ServerNotInitialized" } }, response) + + -- 2. second codelens request runs + response = exec_lua([=[ + CALLED = false + local cmd_called = nil + vim.lsp.commands["Dummy"] = function (command) + cmd_called = command + end + vim.lsp.codelens.refresh() + vim.wait(100, function () return CALLED end) + vim.lsp.codelens.run() + vim.wait(100, function () return cmd_called end) + return cmd_called + ]=]) + eq( { command = "Dummy", title = "Lens1" }, response) + + -- 3. third codelens request runs + response = exec_lua([=[ + CALLED = false + local cmd_called = nil + vim.lsp.commands["Dummy"] = function (command) + cmd_called = command + end + vim.lsp.codelens.refresh() + vim.wait(100, function () return CALLED end) + vim.lsp.codelens.run() + vim.wait(100, function () return cmd_called end) + return cmd_called + ]=]) + eq( { command = "Dummy", title = "Lens2" }, response) + elseif ctx.method == 'shutdown' then + client.stop() + end + end + } + end) end) describe("vim.lsp.buf.format", function() diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index abb0948c60..3320f53d86 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -12,6 +12,7 @@ local nvim_prog = helpers.nvim_prog local iswin = helpers.iswin local exc_exec = helpers.exc_exec local exec_lua = helpers.exec_lua +local poke_eventloop = helpers.poke_eventloop describe('ui/ext_messages', function() local screen @@ -1111,6 +1112,8 @@ describe('ui/ext_messages', function() [3] = {bold = true}, [4] = {bold = true, foreground = Screen.colors.SeaGreen4}, [5] = {foreground = Screen.colors.Blue1}, + [6] = {reverse = true}, + [7] = {bold = true, reverse = true}, }) end) @@ -1202,6 +1205,109 @@ describe('ui/ext_messages', function() {content = { { "Press ENTER or type command to continue", 4 } }, kind = "return_prompt" } }} end) + + it('supports global statusline', function() + feed(":set laststatus=3<cr>") + feed(":sp<cr>") + feed("<c-l>") + feed(":set cmdheight<cr>") + screen:expect({grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {6:────────────────────────────────────────────────────────────────────────────────}| + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {7:[No Name] }| + ]], messages={ + {content = { { " cmdheight=0" } }, kind = "" } + }}) + + feed("<c-w>+") + feed("<c-l>") + feed(":set cmdheight<cr>") + screen:expect({grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {6:────────────────────────────────────────────────────────────────────────────────}| + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {7:[No Name] }| + ]], messages={ + {content = { { " cmdheight=0" } }, kind = "" } + }}) + + feed(":set mouse=a<cr>") + meths.input_mouse('left', 'press', '', 0, 12, 10) + poke_eventloop() + meths.input_mouse('left', 'drag', '', 0, 12, 10) + meths.input_mouse('left', 'drag', '', 0, 11, 10) + feed("<c-l>") + feed(":set cmdheight<cr>") + screen:expect({grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {6:────────────────────────────────────────────────────────────────────────────────}| + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {7:[No Name] }| + ]], messages={ + {content = { { " cmdheight=0" } }, kind = "" } + }}) + end) end) describe('ui/msg_puts_printf', function() |