mirror of
https://github.com/neovim/neovim.git
synced 2025-11-05 10:14:26 +00:00
Merge pull request #18502 from drybalka/fix-languagetree-contains-description
treesitter: small improvements of languagetree.lua
This commit is contained in:
@@ -616,8 +616,6 @@ LanguageTree:children({self}) *LanguageTree:children()*
|
|||||||
LanguageTree:contains({self}, {range}) *LanguageTree:contains()*
|
LanguageTree:contains({self}, {range}) *LanguageTree:contains()*
|
||||||
Determines whether {range} is contained in this language tree
|
Determines whether {range} is contained in this language tree
|
||||||
|
|
||||||
This goes down the tree to recursively check children.
|
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
{range} A range, that is a `{ start_line, start_col,
|
{range} A range, that is a `{ start_line, start_col,
|
||||||
end_line, end_col }` table.
|
end_line, end_col }` table.
|
||||||
|
|||||||
@@ -519,17 +519,11 @@ local function tree_contains(tree, 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
|
return start_fits and end_fits
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Determines whether {range} is contained in this language tree
|
--- Determines whether {range} is contained in this language tree
|
||||||
---
|
---
|
||||||
--- This goes down the tree to recursively check children.
|
|
||||||
---
|
|
||||||
---@param range A range, that is a `{ start_line, start_col, end_line, end_col }` table.
|
---@param range A range, that is a `{ start_line, start_col, end_line, end_col }` table.
|
||||||
function LanguageTree:contains(range)
|
function LanguageTree:contains(range)
|
||||||
for _, tree in pairs(self._trees) do
|
for _, tree in pairs(self._trees) do
|
||||||
|
|||||||
Reference in New Issue
Block a user