fix(lsp): only send diagnostics from current buffer in code_action() (#18655)

Fix vim.lsp.buf.(range_)code_action() to only send diagnostics belonging
to the current buffer and not to other files in the workspace.

(cherry picked from commit e3d660e456)

Co-authored-by: Fredrik Ekre <ekrefredrik@gmail.com>
This commit is contained in:
github-actions[bot]
2022-05-21 16:02:38 +02:00
committed by GitHub
parent 7af873f9d5
commit cb1b4bbeae

View File

@@ -595,7 +595,8 @@ function M.code_action(context)
validate { context = { context, 't', true } }
context = context or {}
if not context.diagnostics then
context.diagnostics = vim.lsp.diagnostic.get_line_diagnostics()
local bufnr = vim.api.nvim_get_current_buf()
context.diagnostics = vim.lsp.diagnostic.get_line_diagnostics(bufnr)
end
local params = util.make_range_params()
params.context = context
@@ -621,7 +622,8 @@ function M.range_code_action(context, start_pos, end_pos)
validate { context = { context, 't', true } }
context = context or {}
if not context.diagnostics then
context.diagnostics = vim.lsp.diagnostic.get_line_diagnostics()
local bufnr = vim.api.nvim_get_current_buf()
context.diagnostics = vim.lsp.diagnostic.get_line_diagnostics(bufnr)
end
local params = util.make_given_range_params(start_pos, end_pos)
params.context = context