mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-18 03:10:04 -04:00
refactor(utils): clean up deprecated code
use `vim.treesitter.is_in_node_range()` directly
This commit is contained in:
parent
2e95d25412
commit
d1d00f46ce
1 changed files with 1 additions and 18 deletions
|
|
@ -294,30 +294,13 @@ function M.node_length(node)
|
||||||
return end_byte - start_byte
|
return end_byte - start_byte
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Determines whether (line, col) position is in node range
|
|
||||||
--- @deprecated Use `vim.treesitter.is_in_node_range()` instead
|
--- @deprecated Use `vim.treesitter.is_in_node_range()` instead
|
||||||
-- @param node Node defining the range
|
|
||||||
-- @param line A line (0-based)
|
|
||||||
-- @param col A column (0-based)
|
|
||||||
function M.is_in_node_range(node, line, col)
|
function M.is_in_node_range(node, line, col)
|
||||||
vim.notify_once(
|
vim.notify_once(
|
||||||
"nvim-treesitter.ts_utils.is_in_node_range is deprecated: use vim.treesitter.is_in_node_range",
|
"nvim-treesitter.ts_utils.is_in_node_range is deprecated: use vim.treesitter.is_in_node_range",
|
||||||
vim.log.levels.WARN
|
vim.log.levels.WARN
|
||||||
)
|
)
|
||||||
local start_line, start_col, end_line, end_col = node:range()
|
return ts.is_in_node_range(node, line, col)
|
||||||
if line >= start_line and line <= end_line then
|
|
||||||
if line == start_line and line == end_line then
|
|
||||||
return col >= start_col and col < end_col
|
|
||||||
elseif line == start_line then
|
|
||||||
return col >= start_col
|
|
||||||
elseif line == end_line then
|
|
||||||
return col < end_col
|
|
||||||
else
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
else
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @deprecated Use `vim.treesitter.get_node_range()` instead
|
--- @deprecated Use `vim.treesitter.get_node_range()` instead
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue