Skip to content

Commit 35e5ce5

Browse files
committed
fix: use non-deprecated iter_matches with all=true
This fixes nightly test failures. This also changes behaviour in complex scenarios most likely, as instead of matching just the last node, we now consider all nodes in the match.
1 parent d0d8bfa commit 35e5ce5

File tree

1 file changed

+21
-17
lines changed
  • lua/typescript-tools/protocol/text_document/code_lens

1 file changed

+21
-17
lines changed

lua/typescript-tools/protocol/text_document/code_lens/init.lua

+21-17
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,30 @@ local M = {}
99
---@param lenses table
1010
---@param implementations boolean|nil
1111
local function convert_nodes_to_response(tree, query, text_document, lenses, implementations)
12-
for _, match in query:iter_matches(tree:root(), vim.uri_to_bufnr(text_document.uri)) do
13-
for id, node in pairs(match) do
12+
for _, match in
13+
query:iter_matches(tree:root(), vim.uri_to_bufnr(text_document.uri), 0, -1, { all = true })
14+
do
15+
for id, nodes in pairs(match) do
1416
local name = query.captures[id]
15-
local start_row, start_col, end_row, end_col = node:range()
17+
for _, node in ipairs(nodes) do
18+
local start_row, start_col, end_row, end_col = node:range()
1619

17-
if config.disable_member_code_lens and name == "member" then
18-
goto continue
19-
end
20+
if config.disable_member_code_lens and name == "member" then
21+
goto continue
22+
end
2023

21-
table.insert(lenses, {
22-
range = {
23-
start = { line = start_row, character = start_col },
24-
["end"] = { line = end_row, character = end_col },
25-
},
26-
data = {
27-
textDocument = text_document,
28-
implementations = implementations,
29-
},
30-
})
31-
::continue::
24+
table.insert(lenses, {
25+
range = {
26+
start = { line = start_row, character = start_col },
27+
["end"] = { line = end_row, character = end_col },
28+
},
29+
data = {
30+
textDocument = text_document,
31+
implementations = implementations,
32+
},
33+
})
34+
::continue::
35+
end
3236
end
3337
end
3438
end

0 commit comments

Comments
 (0)