Skip to content

Commit f230b19

Browse files
committed
chore: mr comments
1 parent 48aa3c0 commit f230b19

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lua/helm-ls/matchparen.lua

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ function M.jump_to_matching_keyword()
5252
local start_nodes, middle_nodes, end_nodes = {}, {}, {}
5353
local cursor_on_node, cursor_on_node_type
5454

55-
for id, node in parts_query:iter_captures(action_node, bufnr) do
55+
local start_row, _, end_row, _ = action_node:range()
56+
for id, node in parts_query:iter_captures(action_node, bufnr, start_row, end_row + 1) do
5657
local is_nested = false
5758
local parent = node:parent()
5859
while parent and parent:id() ~= action_node:id() do
@@ -84,9 +85,14 @@ function M.jump_to_matching_keyword()
8485
end
8586

8687
-- Sort nodes by position
87-
table.sort(start_nodes, function(a, b) return a:start() < b:start() end)
88-
table.sort(middle_nodes, function(a, b) return a:start() < b:start() end)
89-
table.sort(end_nodes, function(a, b) return a:start() < b:start() end)
88+
local function by_pos(a, b)
89+
local ar, ac = a:start()
90+
local br, bc = b:start()
91+
return ar == br and ac < bc or ar < br
92+
end
93+
table.sort(start_nodes, by_pos)
94+
table.sort(middle_nodes, by_pos)
95+
table.sort(end_nodes, by_pos)
9096

9197
-- 3. Jump based on the type of node under the cursor
9298
local function jump_to(node)

0 commit comments

Comments
 (0)