fixed tree-sitter iterators.
This commit is contained in:
parent
cf5c90c079
commit
437ddcbc87
1 changed files with 26 additions and 21 deletions
|
|
@ -89,26 +89,29 @@ function M.get_names_in_buffer(bufnr, line1, line2)
|
||||||
local passed = not range
|
local passed = not range
|
||||||
local name
|
local name
|
||||||
|
|
||||||
for id, node in pairs(match) do
|
for id, nodes in pairs(match) do
|
||||||
local row1, col1, row2, col2 = node:range()
|
for _, node in ipairs(nodes) do
|
||||||
local text = vim.api.nvim_buf_get_text(bufnr, row1, col1, row2, col2, {})[1]
|
local row1, col1, row2, col2 = node:range()
|
||||||
|
|
||||||
if named_blocks_query.captures[id] == "block" and not passed then
|
local text = vim.api.nvim_buf_get_text(bufnr, row1, col1, row2, col2, {})[1]
|
||||||
if single and line1 - 1 > row1 and line1 - 1 < row2 then
|
|
||||||
passed = true
|
if named_blocks_query.captures[id] == "block" and not passed then
|
||||||
elseif not single and line1 - 1 <= row1 and row2 <= line2 - 1 then
|
if single and line1 - 1 > row1 and line1 - 1 < row2 then
|
||||||
passed = true
|
passed = true
|
||||||
|
elseif not single and line1 - 1 <= row1 and row2 <= line2 - 1 then
|
||||||
|
passed = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if named_blocks_query.captures[id] == "name" then
|
||||||
|
name = text
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if named_blocks_query.captures[id] == "name" then
|
if passed then
|
||||||
name = text
|
table.insert(names, name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if passed then
|
|
||||||
table.insert(names, name)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return names
|
return names
|
||||||
end
|
end
|
||||||
|
|
@ -130,14 +133,16 @@ function M.get_blocks_in_buffer(bufnr, line1, line2)
|
||||||
for _, match in unnamed_blocks_query:iter_matches(root, bufnr, 0, -1) do
|
for _, match in unnamed_blocks_query:iter_matches(root, bufnr, 0, -1) do
|
||||||
local passed = not range
|
local passed = not range
|
||||||
|
|
||||||
for id, node in pairs(match) do
|
for id, nodes in pairs(match) do
|
||||||
local row1, _, row2 = node:range()
|
for _, node in ipairs(nodes) do
|
||||||
|
local row1, _, row2 = node:range()
|
||||||
|
|
||||||
if unnamed_blocks_query.captures[id] == "block" and not passed then
|
if unnamed_blocks_query.captures[id] == "block" and not passed then
|
||||||
if single and line1 - 1 > row1 and line1 - 1 < row2 then
|
if single and line1 - 1 > row1 and line1 - 1 < row2 then
|
||||||
passed = true
|
passed = true
|
||||||
elseif not single and line1 - 1 <= row1 and row2 <= line2 - 1 then
|
elseif not single and line1 - 1 <= row1 and row2 <= line2 - 1 then
|
||||||
passed = true
|
passed = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue