feat(vim.pos): accept buf=0 for current buf #39414

This commit is contained in:
Luis Calle
2026-04-26 05:34:18 -05:00
committed by Justin M. Keyes
parent 828a35b14f
commit 49efe692f3
5 changed files with 74 additions and 44 deletions

View File

@@ -20,6 +20,15 @@ describe('vim.pos', function()
eq(buf, pos[3])
end)
it('creates a position with buf=0', function()
local pos, buf = exec_lua(function()
return vim.pos(0, 3, 5), vim.api.nvim_get_current_buf()
end)
eq(3, pos[1])
eq(5, pos[2])
eq(buf, pos[3])
end)
it('comparisons by overloaded operators', function()
local buf = exec_lua(function()
return vim.api.nvim_create_buf(false, true)

View File

@@ -22,6 +22,17 @@ describe('vim.range', function()
eq(buf, range[5])
end)
it('creates a range with buf=0', function()
local range, buf = exec_lua(function()
return vim.range(0, 3, 5, 4, 6), vim.api.nvim_get_current_buf()
end)
eq(3, range[1])
eq(5, range[2])
eq(4, range[3])
eq(6, range[4])
eq(buf, range[5])
end)
it('creates a range from two positions', function()
local range, buf1 = exec_lua(function()
local buf = vim.api.nvim_create_buf(false, true)