From c31bc6ea731567db86cbe91f7c62d89c612cd3ac Mon Sep 17 00:00:00 2001 From: Michael Lingelbach Date: Wed, 14 Jul 2021 09:15:43 -0700 Subject: [PATCH] fix(lsp): pass bufnr for async formatting (#15084) the `textDocument/rangeFormatting` nad `textDocument/formatting` did not pass bufnr to apply_text_edits, meaning edits were applied to the user's currently active buffer. This could result in text being applied to the wrong buffer. --- runtime/lua/vim/lsp/handlers.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua index 4c7cb28871..797ff762cb 100644 --- a/runtime/lua/vim/lsp/handlers.lua +++ b/runtime/lua/vim/lsp/handlers.lua @@ -223,15 +223,15 @@ M['textDocument/rename'] = function(_, _, result) end --@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_rangeFormatting -M['textDocument/rangeFormatting'] = function(_, _, result) +M['textDocument/rangeFormatting'] = function(_, _, result, _, bufnr) if not result then return end - util.apply_text_edits(result) + util.apply_text_edits(result, bufnr) end --@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_formatting -M['textDocument/formatting'] = function(_, _, result) +M['textDocument/formatting'] = function(_, _, result, _, bufnr) if not result then return end - util.apply_text_edits(result) + util.apply_text_edits(result, bufnr) end --@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_completion