Skip to content

Commit

Permalink
Merge pull request #208 from sainnhe/avoid-goto
Browse files Browse the repository at this point in the history
Avoid goto logic in internal.lua
  • Loading branch information
andymass authored Feb 4, 2022
2 parents 07196cf + cfb8390 commit 0fd7055
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions lua/treesitter-matchup/internal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -191,25 +191,21 @@ function M.get_delim(bufnr, opts)
local smallest_len = 1e31
local result_info = nil
for _, side in ipairs(side_table[opts.side]) do
if side == 'mid' and vim.g.matchup_delim_nomids > 0 then
goto continue
end

for _, node in ipairs(active_nodes[side]) do
if ts_utils.is_in_node_range(node, cursor[1]-1, cursor[2]) then
local len = ts_utils.node_length(node)
if len < smallest_len then
smallest_len = len
result_info = {
node = node,
side = side,
key = symbols[_node_id(node)]
}
if not(side == 'mid' and vim.g.matchup_delim_nomids > 0) then
for _, node in ipairs(active_nodes[side]) do
if ts_utils.is_in_node_range(node, cursor[1]-1, cursor[2]) then
local len = ts_utils.node_length(node)
if len < smallest_len then
smallest_len = len
result_info = {
node = node,
side = side,
key = symbols[_node_id(node)]
}
end
end
end
end

::continue::
end

if result_info then
Expand Down

0 comments on commit 0fd7055

Please sign in to comment.