aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/buf.lua
diff options
context:
space:
mode:
authorFredrik Ekre <ekrefredrik@gmail.com>2022-05-20 13:11:23 +0200
committerGitHub <noreply@github.com>2022-05-20 13:11:23 +0200
commita4862cbb5fe4fb368a679adf198506a56a104413 (patch)
treea1215f16fe712c246a8d70e81d4faf0a9f00f72d /runtime/lua/vim/lsp/buf.lua
parenteb0aa8bb0ebc3cc233af6a5281c553d14ee57183 (diff)
downloadrneovim-a4862cbb5fe4fb368a679adf198506a56a104413.tar.gz
rneovim-a4862cbb5fe4fb368a679adf198506a56a104413.tar.bz2
rneovim-a4862cbb5fe4fb368a679adf198506a56a104413.zip
fix(lsp): only send diagnostics from current buffer in code_action() (#18639)
Fix vim.lsp.buf.(range_)code_action() to only send diagnostics belonging to the current buffer and not to other files in the workspace.
Diffstat (limited to 'runtime/lua/vim/lsp/buf.lua')
-rw-r--r--runtime/lua/vim/lsp/buf.lua6
1 files changed, 4 insertions, 2 deletions
diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua
index 80350bcb71..1207da094a 100644
--- a/runtime/lua/vim/lsp/buf.lua
+++ b/runtime/lua/vim/lsp/buf.lua
@@ -863,7 +863,8 @@ function M.code_action(options)
end
local context = options.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
@@ -889,7 +890,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