Skip to content
forked from neovim/neovim

Commit

Permalink
fix(lsp): only send diagnostics from current buffer in code_action() (n…
Browse files Browse the repository at this point in the history
…eovim#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 e3d660e)

Co-authored-by: Fredrik Ekre <ekrefredrik@gmail.com>
  • Loading branch information
github-actions[bot] and fredrikekre committed May 21, 2022
1 parent 7af873f commit cb1b4bb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions runtime/lua/vim/lsp/buf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit cb1b4bb

Please sign in to comment.