From 5d1f50117b7be4503a251747798e76bed70b5e31 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Fri, 7 Feb 2025 15:23:50 -0800 Subject: [PATCH] refactor: Improve file lookup logic in get_scm_fname --- aider/repomap.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/aider/repomap.py b/aider/repomap.py index b184b6566..cdf047936 100644 --- a/aider/repomap.py +++ b/aider/repomap.py @@ -735,11 +735,19 @@ def get_scm_fname(lang): # Load the tags queries if USING_TSL_PACK: subdir = "tree-sitter-language-pack" - # check this subdir first, if file exists, return it otherwise check the other. ai! - else: - subdir = "tree-sitter-languages" - + try: + path = resources.files(__package__).joinpath( + "queries", + subdir, + f"tree-sitter-{lang}-tags.scm", + ) + if path.exists(): + return path + except KeyError: + pass + # Fall back to tree-sitter-languages + subdir = "tree-sitter-languages" try: return resources.files(__package__).joinpath( "queries",