aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim
diff options
context:
space:
mode:
authorfrancisco souza <108725+fsouza@users.noreply.github.com>2020-11-07 14:31:55 -0800
committerGitHub <noreply@github.com>2020-11-07 23:31:55 +0100
commit5161ff88fa6b7464fc9554b5d456bd08e3644ace (patch)
treeb6115ed9e130496ccea93ca5facf806a073704de /runtime/lua/vim
parentdf750e7248a38b18a49546d38e3a4777ad90b520 (diff)
downloadrneovim-5161ff88fa6b7464fc9554b5d456bd08e3644ace.tar.gz
rneovim-5161ff88fa6b7464fc9554b5d456bd08e3644ace.tar.bz2
rneovim-5161ff88fa6b7464fc9554b5d456bd08e3644ace.zip
lsp: fix formatting_sync with multiple clients (#13233)
buf_request_sync returns a table indexed by the client id, so when starting a second client on a separate buffer, result[1] will be nil. Closes #13232. Co-authored-by: francisco souza <fsouza@users.noreply.github.com>
Diffstat (limited to 'runtime/lua/vim')
-rw-r--r--runtime/lua/vim/lsp/buf.lua5
1 files changed, 3 insertions, 2 deletions
diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua
index c015884f5b..0b8e08f36c 100644
--- a/runtime/lua/vim/lsp/buf.lua
+++ b/runtime/lua/vim/lsp/buf.lua
@@ -138,8 +138,9 @@ end
function M.formatting_sync(options, timeout_ms)
local params = util.make_formatting_params(options)
local result = vim.lsp.buf_request_sync(0, "textDocument/formatting", params, timeout_ms)
- if not result then return end
- result = result[1].result
+ if not result or vim.tbl_isempty(result) then return end
+ local _, formatting_result = next(result)
+ result = formatting_result.result
if not result then return end
vim.lsp.util.apply_text_edits(result)
end