From 2a56d892d772c5d846925585a30e081154596502 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Fri, 7 Feb 2025 16:18:09 -0800 Subject: [PATCH] works with both tsl and tsl-pack --- aider/repomap.py | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/aider/repomap.py b/aider/repomap.py index 4379cc0af..4d903004b 100644 --- a/aider/repomap.py +++ b/aider/repomap.py @@ -285,26 +285,32 @@ class RepoMap: captures = query.captures(tree.root_node) saw = set() - for tag, nodes in captures.items(): - for node in nodes: - if tag.startswith("name.definition."): - kind = "def" - elif tag.startswith("name.reference."): - kind = "ref" - else: - continue + if USING_TSL_PACK: + all_nodes = [] + for tag, nodes in captures.items(): + all_nodes += [(node, tag) for node in nodes] + else: + all_nodes = list(captures) - saw.add(kind) + for node, tag in all_nodes: + if tag.startswith("name.definition."): + kind = "def" + elif tag.startswith("name.reference."): + kind = "ref" + else: + continue - result = Tag( - rel_fname=rel_fname, - fname=fname, - name=node.text.decode("utf-8"), - kind=kind, - line=node.start_point[0], - ) + saw.add(kind) - yield result + result = Tag( + rel_fname=rel_fname, + fname=fname, + name=node.text.decode("utf-8"), + kind=kind, + line=node.start_point[0], + ) + + yield result if "ref" in saw: return