From 4dc2e6a5c864ec97dd2eab8a24cbb2a0e2e13dc9 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sat, 27 May 2023 08:31:42 -0700 Subject: [PATCH] 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`. --- aider/coder.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/aider/coder.py b/aider/coder.py index 4a7fdee52..7dd8153e9 100755 --- a/aider/coder.py +++ b/aider/coder.py @@ -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