Added tests to exercise all combinations of path formats for get_file_mentions and get_addable_relative_files, and updated the get_file_mentions method to handle both Unix and Windows path formats.

This commit is contained in:
Paul Gauthier (aider) 2024-07-18 15:19:32 +01:00
parent c076c134ac
commit 07550d6f5f
2 changed files with 34 additions and 2 deletions

View file

@ -1062,13 +1062,14 @@ class Coder:
mentioned_rel_fnames = set()
fname_to_rel_fnames = {}
for rel_fname in addable_rel_fnames:
if rel_fname in words:
normalized_rel_fname = rel_fname.replace('\\', '/')
if normalized_rel_fname in words or rel_fname in words:
mentioned_rel_fnames.add(str(rel_fname))
fname = os.path.basename(rel_fname)
# Don't add basenames that could be plain words like "run" or "make"
if "/" in fname or "." in fname or "_" in fname or "-" in fname:
if "/" in fname or "\\" in fname or "." in fname or "_" in fname or "-" in fname:
if fname not in fname_to_rel_fnames:
fname_to_rel_fnames[fname] = []
fname_to_rel_fnames[fname].append(rel_fname)