mirror of
https://github.com/neovim/neovim.git
synced 2026-09-03 21:00:34 +00:00
fix(vim.version): fix metatable for intersections #41615
Problem: `vim.version.intersect()` returns tables with `VersionRange` (method table) as their metatable. Although the calculated bounds are correct, the results do not expose `VersionRange` methods. Solution: Construct intersection tables with `range_mt`, matching `vim.version.range()`. Add assertions covering method access and repeated intersection.
This commit is contained in:
committed by
GitHub
parent
a41d008666
commit
8321941ff2
@@ -381,7 +381,7 @@ function M.intersect(r1, r2)
|
||||
local from = r1.from <= r2.from and r2.from or r1.from
|
||||
local to = (r1.to == nil or (r2.to ~= nil and r2.to <= r1.to)) and r2.to or r1.to
|
||||
if to == nil or from < to or (from == to and r1:has(from) and r2:has(from)) then
|
||||
return setmetatable({ from = from, to = to }, VersionRange)
|
||||
return setmetatable({ from = from, to = to }, range_mt)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user