mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 11:58:17 +00:00
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:
![41898282+github-actions[bot]@users.noreply.github.com](/assets/img/avatar_default.png)
committed by
GitHub

parent
7af873f9d5
commit
cb1b4bbeae
@@ -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
|
||||
|
Reference in New Issue
Block a user