diff options
author | Mathias Fußenegger <mfussenegger@users.noreply.github.com> | 2021-09-22 00:05:49 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2021-09-26 10:25:17 -0700 |
commit | 27bac13be66946e2cb2912a44185d18b0f856a32 (patch) | |
tree | 4da8dd76dde3ec1e4f4a73a7086f6bc1a886a632 /runtime/lua/vim/lsp/buf.lua | |
parent | d26d489e2e5986c8201af8e3e1e8b860adb57afc (diff) | |
download | rneovim-27bac13be66946e2cb2912a44185d18b0f856a32.tar.gz rneovim-27bac13be66946e2cb2912a44185d18b0f856a32.tar.bz2 rneovim-27bac13be66946e2cb2912a44185d18b0f856a32.zip |
fix(lsp): update lsp-handler signature in call_hierarchy (#15738)
This fixes the handler signature and also prevents n+1 requests firing
if there are multiple clients.
(The first `prepareCallHierarchy` handler is called once per client,
each invocation used `buf_request` to make more requests using *all*
clients)
Diffstat (limited to 'runtime/lua/vim/lsp/buf.lua')
-rw-r--r-- | runtime/lua/vim/lsp/buf.lua | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua index 8dfd5c9c5b..bdd5a6c6bb 100644 --- a/runtime/lua/vim/lsp/buf.lua +++ b/runtime/lua/vim/lsp/buf.lua @@ -300,13 +300,21 @@ end --@private local function call_hierarchy(method) local params = util.make_position_params() - request('textDocument/prepareCallHierarchy', params, function(err, _, result) + request('textDocument/prepareCallHierarchy', params, function(err, result, ctx) if err then vim.notify(err.message, vim.log.levels.WARN) return end local call_hierarchy_item = pick_call_hierarchy_item(result) - vim.lsp.buf_request(0, method, { item = call_hierarchy_item }) + local client = vim.lsp.get_client_by_id(ctx.client_id) + if client then + client.request(method, { item = call_hierarchy_item }, nil, ctx.bufnr) + else + vim.notify(string.format( + 'Client with id=%d disappeared during call hierarchy request', ctx.client_id), + vim.log.levels.WARN + ) + end end) end |