feat(vim.pos)!: require buf param on vim.pos, vim.range #38665

Problem: `buf` is optional even though its needed to perform conversions
and the ordering of `(buf, row, col)` is not consistent.

Solution: make `buf` mandatory on `vim.range` and `vim.pos` and enforce
the `buf, row, col` ordering
This commit is contained in:
Luis Calle
2026-04-06 10:51:36 -05:00
committed by GitHub
parent 595e58f47f
commit 01be30f638
8 changed files with 115 additions and 175 deletions

View File

@@ -223,7 +223,8 @@ function Completor:show(hint)
if current.range then
row, col = current.range:to_extmark()
else
row, col = vim.pos.cursor(api.nvim_win_get_cursor(vim.fn.bufwinid(self.bufnr))):to_extmark()
row, col =
vim.pos.cursor(self.bufnr, api.nvim_win_get_cursor(vim.fn.bufwinid(self.bufnr))):to_extmark()
end
-- To ensure that virtual text remains visible continuously (without flickering)
@@ -245,7 +246,7 @@ function Completor:show(hint)
-- At least, characters before the cursor should be skipped.
if api.nvim_win_get_buf(winid) == self.bufnr then
local cursor_row, cursor_col =
vim.pos.cursor(api.nvim_win_get_cursor(winid), { buf = self.bufnr }):to_extmark()
vim.pos.cursor(self.bufnr, api.nvim_win_get_cursor(winid)):to_extmark()
if row == cursor_row then
skip = math.max(skip, cursor_col - col + 1)
end