diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/api/autocmd_spec.lua | 3 | ||||
-rw-r--r-- | test/functional/fixtures/fake-lsp-server.lua | 46 | ||||
-rw-r--r-- | test/functional/plugin/lsp_spec.lua | 81 | ||||
-rw-r--r-- | test/functional/ui/messages_spec.lua | 106 |
4 files changed, 230 insertions, 6 deletions
diff --git a/test/functional/api/autocmd_spec.lua b/test/functional/api/autocmd_spec.lua index a30af63ba1..41de308a2c 100644 --- a/test/functional/api/autocmd_spec.lua +++ b/test/functional/api/autocmd_spec.lua @@ -444,6 +444,7 @@ describe('autocmd api', function() eq(1, #aus) eq([[:echo "GroupOne:1"]], aus[1].command) + eq("GroupOne", aus[1].group_name) end) it('should return only the group specified, multiple values', function() @@ -454,7 +455,9 @@ describe('autocmd api', function() eq(2, #aus) eq([[:echo "GroupTwo:2"]], aus[1].command) + eq("GroupTwo", aus[1].group_name) eq([[:echo "GroupTwo:3"]], aus[2].command) + eq("GroupTwo", aus[2].group_name) end) end) diff --git a/test/functional/fixtures/fake-lsp-server.lua b/test/functional/fixtures/fake-lsp-server.lua index 79a29cd8d8..f589f5955f 100644 --- a/test/functional/fixtures/fake-lsp-server.lua +++ b/test/functional/fixtures/fake-lsp-server.lua @@ -222,10 +222,6 @@ function tests.prepare_rename_error() expect_request('textDocument/prepareRename', function() return {}, nil end) - expect_request('textDocument/rename', function(params) - assert_eq(params.newName, 'renameto') - return nil, nil - end) notify('shutdown') end; } @@ -792,6 +788,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..33a8976b79 100644 --- a/test/functional/plugin/lsp_spec.lua +++ b/test/functional/plugin/lsp_spec.lua @@ -2636,10 +2636,8 @@ describe('LSP', function() name = "prepare_rename_error", expected_handlers = { {NIL, {}, {method="shutdown", client_id=1}}; - {NIL, NIL, {method="textDocument/rename", client_id=1, bufnr=1}}; {NIL, {}, {method="start", client_id=1}}; }, - expected_text = "two", -- see test case }, }) do it(test.it, function() @@ -2833,6 +2831,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() |