mirror of
https://github.com/neovim/neovim.git
synced 2025-11-05 18:24:22 +00:00
fix(languagetree): use tree nodes instead of regions in contains
This commit is contained in:
committed by
Steven Sojka
parent
d9c1586e4a
commit
ed558e269a
@@ -425,23 +425,21 @@ function LanguageTree:register_cbs(cbs)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function region_contains(region, range)
|
local function tree_contains(tree, range)
|
||||||
for _, node in ipairs(region) do
|
local start_row, start_col, end_row, end_col = tree:root():range()
|
||||||
local start_row, start_col, end_row, end_col = node:range()
|
|
||||||
local start_fits = start_row < range[1] or (start_row == range[1] and start_col <= range[2])
|
local start_fits = start_row < range[1] or (start_row == range[1] and start_col <= range[2])
|
||||||
local end_fits = end_row > range[3] or (end_row == range[3] and end_col >= range[4])
|
local end_fits = end_row > range[3] or (end_row == range[3] and end_col >= range[4])
|
||||||
|
|
||||||
if start_fits and end_fits then
|
if start_fits and end_fits then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
function LanguageTree:contains(range)
|
function LanguageTree:contains(range)
|
||||||
for _, region in pairs(self._regions) do
|
for _, tree in pairs(self._trees) do
|
||||||
if region_contains(region, range) then
|
if tree_contains(tree, range) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user