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.
This commit is contained in:
Michael Lingelbach 2021-07-14 09:15:43 -07:00 committed by GitHub
parent 02bf251bb3
commit c31bc6ea73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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