mirror of
https://github.com/neovim/neovim.git
synced 2025-10-26 12:27:24 +00:00
fix(treesitter): is_in_node_range (#22582)
TS ranges are end column exclusive, so fix is_in_node_range to account for that.
This commit is contained in:
@@ -191,7 +191,7 @@ end
|
||||
---
|
||||
---@return boolean True if the position is in node range
|
||||
function M.is_in_node_range(node, line, col)
|
||||
return M.node_contains(node, { line, col, line, col })
|
||||
return M.node_contains(node, { line, col, line, col + 1 })
|
||||
end
|
||||
|
||||
--- Determines if a node contains a range
|
||||
@@ -202,7 +202,8 @@ end
|
||||
---@return boolean True if the {node} contains the {range}
|
||||
function M.node_contains(node, range)
|
||||
vim.validate({
|
||||
node = { node, 'userdata' },
|
||||
-- allow a table so nodes can be mocked
|
||||
node = { node, { 'userdata', 'table' } },
|
||||
range = { range, Range.validate, 'integer list with 4 or 6 elements' },
|
||||
})
|
||||
return Range.contains({ node:range() }, range)
|
||||
|
||||
Reference in New Issue
Block a user