refactor(treesitter): simplify some range functions

This commit is contained in:
Lewis Russell
2023-03-06 10:57:14 +00:00
committed by GitHub
parent b0620ffe5a
commit f9a46391ab
2 changed files with 27 additions and 19 deletions

View File

@@ -53,6 +53,26 @@ M.cmp_pos = {
setmetatable(M.cmp_pos, { __call = cmp_pos })
---@private
---Check if a variable is a valid range object
---@param r any
---@return boolean
function M.validate(r)
if type(r) ~= 'table' or #r ~= 6 and #r ~= 4 then
return false
end
for _, e in
ipairs(r --[[@as any[] ]])
do
if type(e) ~= 'number' then
return false
end
end
return true
end
---@private
---@param r1 Range4|Range6
---@param r2 Range4|Range6