1
mirror of https://github.com/neovim/neovim.git synced 2025-01-02 17:33:28 -07:00

Merge pull request from fsouza/fix-callback-logic

[RDY] lsp: fix fallback for callback in method_unsupported
This commit is contained in:
Matthieu Coudron 2020-10-25 22:09:41 +01:00 committed by GitHub
commit a22fe09b90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions
runtime/lua/vim
test/functional/plugin

View File

@ -1029,7 +1029,7 @@ function lsp.buf_request(bufnr, method, params, callback)
-- error message.
if not method_supported then
local unsupported_err = lsp._unsupported_method(method)
local cb = callback or lsp.callbacks['method']
local cb = callback or lsp.callbacks[method]
if cb then
cb(unsupported_err, method, bufnr)
end

View File

@ -323,6 +323,9 @@ describe('LSP', function()
test_name = "capabilities_for_client_supports_method";
on_setup = function()
exec_lua([=[
vim.lsp.callbacks['textDocument/hover'] = function(err, method)
vim.lsp._last_lsp_callback = { err = err; method = method }
end
vim.lsp._unsupported_method = function(method)
vim.lsp._last_unsupported_method = method
return 'fake-error'
@ -334,6 +337,9 @@ describe('LSP', function()
client.stop()
local method = exec_lua("return vim.lsp._last_unsupported_method")
eq("textDocument/hover", method)
local lsp_cb_call = exec_lua("return vim.lsp._last_lsp_callback")
eq("fake-error", lsp_cb_call.err)
eq("textDocument/hover", lsp_cb_call.method)
end;
on_exit = function(code, signal)
eq(0, code, "exit code", fake_lsp_logfile)