fix: resolve nil arguments to API functions (#16889)

As revealed by #16745, some functions pass a nil value to API functions,
which have been implicitly converted to 0. #16745 breaks this implicit
conversion, so explicitly pass a resolved buffer number to these API
functions.
This commit is contained in:
Gregory Anders
2022-01-03 06:48:01 -07:00
committed by GitHub
parent 2f31e7b88b
commit 36662c9612
2 changed files with 10 additions and 10 deletions

View File

@@ -1677,7 +1677,7 @@ function M.symbols_to_items(symbols, bufnr)
end
return _items
end
return _symbols_to_items(symbols, {}, bufnr)
return _symbols_to_items(symbols, {}, bufnr or 0)
end
--- Removes empty lines from the beginning and end.
@@ -1796,7 +1796,7 @@ end
---@returns { textDocument = { uri = `current_file_uri` }, range = { start =
---`current_position`, end = `current_position` } }
function M.make_range_params(window, offset_encoding)
local buf = vim.api.nvim_win_get_buf(window)
local buf = vim.api.nvim_win_get_buf(window or 0)
offset_encoding = offset_encoding or M._get_offset_encoding(buf)
local position = make_position_param(window, offset_encoding)
return {