mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
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>
This commit is contained in:
parent
df750e7248
commit
5161ff88fa
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user