aider: Enhanced check_for_file_mentions to match filenames without the path and add the correct fully pathed file to abs_fnames.

# Context:
USER: the test_check_for_filename_mentions_of_longer_paths is failing. because check_for_file_mentions only matches on the full path. enhance check_for_file_mentions so that if the filename is mentioned without the path, it still adds the correct fully pathed file to abs_fnames
ASSISTANT: To enhance the `check_for_file_mentions` method to match filenames without the path and add the correct fully pathed file to `abs_fnames`, update the method as follows:

```python
aider/coder.py
<<<<<<< ORIGINAL
        for word in words:
            if word in addable_rel_fnames:
                mentioned_rel_fnames.add(word)
=======
        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)
>>>>>>> UPDATED
```

This change will ensure that the method matches filenames without the path and adds the correct fully pathed file to `abs_fnames`.
This commit is contained in:
Paul Gauthier 2023-05-27 08:31:42 -07:00
parent c8cf78b5cf
commit 4dc2e6a5c8

View file

@ -344,9 +344,10 @@ class Coder:
)
mentioned_rel_fnames = set()
for word in words:
if word in addable_rel_fnames:
mentioned_rel_fnames.add(word)
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)
if not mentioned_rel_fnames:
return