aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/util.lua
diff options
context:
space:
mode:
authorMichael Lingelbach <m.j.lbach@gmail.com>2022-01-08 02:30:59 -0800
committerGitHub <noreply@github.com>2022-01-08 11:30:59 +0100
commitb65a23a13a29176aa669afc5d1c906d1d51e0a39 (patch)
treea675e3b9036242d70b4ab3468c245d3150138841 /runtime/lua/vim/lsp/util.lua
parente92b816336a04c18c4aa78eb180158a2bc02ace4 (diff)
downloadrneovim-b65a23a13a29176aa669afc5d1c906d1d51e0a39.tar.gz
rneovim-b65a23a13a29176aa669afc5d1c906d1d51e0a39.tar.bz2
rneovim-b65a23a13a29176aa669afc5d1c906d1d51e0a39.zip
fix(lsp): resolve bufnr for get_lines (#16986)
Closes https://github.com/neovim/neovim/issues/16985 * get_lines checks if buf_loaded using bufnr 0, which is typically used as a sentinel value, but here must be resolved to the true bufnr
Diffstat (limited to 'runtime/lua/vim/lsp/util.lua')
-rw-r--r--runtime/lua/vim/lsp/util.lua7
1 files changed, 6 insertions, 1 deletions
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index 0af4fcb036..89c5ebe8f7 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -193,6 +193,11 @@ end
local function get_lines(bufnr, rows)
rows = type(rows) == "table" and rows or { rows }
+ -- This is needed for bufload and bufloaded
+ if bufnr == 0 then
+ bufnr = vim.api.nvim_get_current_buf()
+ end
+
---@private
local function buf_lines()
local lines = {}
@@ -1814,7 +1819,7 @@ function M.make_given_range_params(start_pos, end_pos, bufnr, offset_encoding)
end_pos = {end_pos, 't', true};
offset_encoding = {offset_encoding, 's', true};
}
- bufnr = bufnr or 0
+ bufnr = bufnr or vim.api.nvim_get_current_buf()
offset_encoding = offset_encoding or M._get_offset_encoding(bufnr)
local A = list_extend({}, start_pos or api.nvim_buf_get_mark(bufnr, '<'))
local B = list_extend({}, end_pos or api.nvim_buf_get_mark(bufnr, '>'))