refactor: Improve file lookup logic in get_scm_fname

This commit is contained in:
Paul Gauthier (aider) 2025-02-07 15:23:50 -08:00
parent f6a2ec15d7
commit 5d1f50117b

View file

@ -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",