mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-22 21:34:59 +00:00
aider: Updated check_for_file_mentions to only add a filename match if it is unambiguous and no other addable_rel_fnames have a basename that also matches.
# Context: USER: on check_for_file_mentions, only add a fname match if it is unambiguous and no other addable_rel_fnames have a basename that also matches ASSISTANT: To update the `check_for_file_mentions` method to only add a filename match if it is unambiguous and no other `addable_rel_fnames` have a basename that also matches, modify the method as follows: ```python aider/coder.py <<<<<<< ORIGINAL for rel_fname in addable_rel_fnames: fname = os.path.basename(rel_fname) if fname in words or rel_fname in words: mentioned_rel_fnames.add(rel_fname) ======= fname_to_rel_fnames = {} for rel_fname in addable_rel_fnames: fname = os.path.basename(rel_fname) if fname not in fname_to_rel_fnames: fname_to_rel_fnames[fname] = [] fname_to_rel_fnames[fname].append(rel_fname) for fname, rel_fnames in fname_to_rel_fnames.items(): if len(rel_fnames) == 1 and (fname in words or rel_fnames[0] in words): mentioned_rel_fnames.add(rel_fnames[0]) >>>>>>> UPDATED ``` This change will ensure that the method only adds a filename match if it is unambiguous and no other `addable_rel_fnames` have a basename that also matches.
This commit is contained in:
parent
3732f62a9c
commit
08164034ff
1 changed files with 8 additions and 2 deletions
|
@ -344,10 +344,16 @@ class Coder:
|
||||||
)
|
)
|
||||||
|
|
||||||
mentioned_rel_fnames = set()
|
mentioned_rel_fnames = set()
|
||||||
|
fname_to_rel_fnames = {}
|
||||||
for rel_fname in addable_rel_fnames:
|
for rel_fname in addable_rel_fnames:
|
||||||
fname = os.path.basename(rel_fname)
|
fname = os.path.basename(rel_fname)
|
||||||
if fname in words or rel_fname in words:
|
if fname not in fname_to_rel_fnames:
|
||||||
mentioned_rel_fnames.add(rel_fname)
|
fname_to_rel_fnames[fname] = []
|
||||||
|
fname_to_rel_fnames[fname].append(rel_fname)
|
||||||
|
|
||||||
|
for fname, rel_fnames in fname_to_rel_fnames.items():
|
||||||
|
if len(rel_fnames) == 1 and (fname in words or rel_fnames[0] in words):
|
||||||
|
mentioned_rel_fnames.add(rel_fnames[0])
|
||||||
|
|
||||||
if not mentioned_rel_fnames:
|
if not mentioned_rel_fnames:
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue