diff options
author | Mathias Fußenegger <mfussenegger@users.noreply.github.com> | 2022-06-05 16:43:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-05 16:43:32 +0200 |
commit | e4df1c9b9e61e79234684d30ca700b42f82bc34a (patch) | |
tree | fc369803d77a91e530b74ccc9eb0c08501c2b5c9 /test/functional/plugin | |
parent | 214f866fe50737152f87ec04824f5e0f1d39edc2 (diff) | |
download | rneovim-e4df1c9b9e61e79234684d30ca700b42f82bc34a.tar.gz rneovim-e4df1c9b9e61e79234684d30ca700b42f82bc34a.tar.bz2 rneovim-e4df1c9b9e61e79234684d30ca700b42f82bc34a.zip |
fix(lsp): fix multi client handling in code action (#18869)
Fixes https://github.com/neovim/neovim/issues/18860
Diffstat (limited to 'test/functional/plugin')
-rw-r--r-- | test/functional/plugin/lsp_spec.lua | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua index 05ea6f7523..22e2354723 100644 --- a/test/functional/plugin/lsp_spec.lua +++ b/test/functional/plugin/lsp_spec.lua @@ -2793,6 +2793,45 @@ describe('LSP', function() end } end) + it('Calls workspace/executeCommand if no client side command', function() + local client + local expected_handlers = { + { NIL, {}, { method = 'shutdown', client_id = 1 } }, + { + NIL, + { command = 'dummy1', title = 'Command 1' }, + { bufnr = 1, method = 'workspace/executeCommand', client_id = 1 }, + }, + { NIL, {}, { method = 'start', client_id = 1 } }, + } + test_rpc_server({ + test_name = 'code_action_server_side_command', + on_init = function(client_) + client = client_ + end, + on_setup = function() 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) + ctx.params = nil -- don't compare in assert + eq(table.remove(expected_handlers), { err, result, ctx }) + if ctx.method == 'start' then + exec_lua([[ + local bufnr = vim.api.nvim_get_current_buf() + vim.lsp.buf_attach_client(bufnr, TEST_RPC_CLIENT_ID) + vim.fn.inputlist = function() + return 1 + end + vim.lsp.buf.code_action() + ]]) + elseif ctx.method == 'shutdown' then + client.stop() + end + end, + }) + end) it('Filters and automatically applies action if requested', function() local client local expected_handlers = { |