diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/functional/fixtures/fake-lsp-server.lua | 29 | ||||
| -rw-r--r-- | test/functional/plugin/lsp_spec.lua | 39 | 
2 files changed, 68 insertions, 0 deletions
| diff --git a/test/functional/fixtures/fake-lsp-server.lua b/test/functional/fixtures/fake-lsp-server.lua index 9bceb612a5..0dc0c8c2db 100644 --- a/test/functional/fixtures/fake-lsp-server.lua +++ b/test/functional/fixtures/fake-lsp-server.lua @@ -757,6 +757,35 @@ function tests.code_action_with_resolve()    }  end +function tests.code_action_server_side_command() +  skeleton({ +    on_init = function() +      return { +        capabilities = { +          codeActionProvider = { +            resolveProvider = false, +          }, +        }, +      } +    end, +    body = function() +      notify('start') +      local cmd = { +        title = 'Command 1', +        command = 'dummy1', +      } +      expect_request('textDocument/codeAction', function() +        return nil, { cmd } +      end) +      expect_request('workspace/executeCommand', function() +        return nil, cmd +      end) +      notify('shutdown') +    end, +  }) +end + +  function tests.code_action_filter()    skeleton {      on_init = function() 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 = { | 
