diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/functional/fixtures/fake-lsp-server.lua | 14 | ||||
| -rw-r--r-- | test/functional/plugin/lsp_spec.lua | 45 |
2 files changed, 54 insertions, 5 deletions
diff --git a/test/functional/fixtures/fake-lsp-server.lua b/test/functional/fixtures/fake-lsp-server.lua index 5d7ab2ad12..6798d53d2b 100644 --- a/test/functional/fixtures/fake-lsp-server.lua +++ b/test/functional/fixtures/fake-lsp-server.lua @@ -789,15 +789,19 @@ function tests.code_action_with_resolve() end, body = function() notify('start') - local cmd = { - title = 'Command 1', - command = 'dummy1', - } + local cmd = { title = 'Action 1' } expect_request('textDocument/codeAction', function() return nil, { cmd } end) expect_request('codeAction/resolve', function() - return nil, cmd + return nil, + { + title = 'Action 1', + command = { + title = 'Command 1', + command = 'dummy1', + }, + } end) notify('shutdown') end, diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua index 17e3fbbf70..33dfae6b12 100644 --- a/test/functional/plugin/lsp_spec.lua +++ b/test/functional/plugin/lsp_spec.lua @@ -4591,6 +4591,51 @@ describe('LSP', function() eq('workspace/executeCommand', result[5].method) eq('command:1', result[5].params.command) end) + + it('Resolves command property', function() + clear() + exec_lua(create_server_definition) + local result = exec_lua(function() + local server = _G._create_server({ + capabilities = { + executeCommandProvider = { + commands = { 'command:1' }, + }, + codeActionProvider = { + resolveProvider = true, + }, + }, + handlers = { + ['textDocument/codeAction'] = function(_, _, callback) + callback(nil, { + { title = 'Code Action 1' }, + }) + end, + ['codeAction/resolve'] = function(_, _, callback) + callback(nil, { + title = 'Code Action 1', + command = { + title = 'Command 1', + command = 'command:1', + }, + }) + end, + }, + }) + + local client_id = assert(vim.lsp.start({ + name = 'dummy', + cmd = server.cmd, + })) + + vim.lsp.buf.code_action({ apply = true }) + vim.lsp.stop_client(client_id) + return server.messages + end) + eq('codeAction/resolve', result[4].method) + eq('workspace/executeCommand', result[5].method) + eq('command:1', result[5].params.command) + end) end) describe('vim.lsp.commands', function() |