mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 14:25:00 +00:00
refac
This commit is contained in:
parent
851e98a398
commit
73e6949287
2 changed files with 13 additions and 21 deletions
|
@ -762,7 +762,7 @@ class Coder:
|
|||
)
|
||||
]
|
||||
|
||||
def check_for_file_mentions(self, content):
|
||||
def get_file_mentions(self, content):
|
||||
words = set(word for word in content.split())
|
||||
|
||||
# drop sentence punctuation from the end
|
||||
|
@ -781,14 +781,22 @@ class Coder:
|
|||
mentioned_rel_fnames.add(str(rel_fname))
|
||||
|
||||
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)
|
||||
|
||||
# Don't add basenames that could be plain words like "run" or "make"
|
||||
if "/" 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)
|
||||
|
||||
for fname, rel_fnames in fname_to_rel_fnames.items():
|
||||
if len(rel_fnames) == 1 and fname in words:
|
||||
mentioned_rel_fnames.add(rel_fnames[0])
|
||||
|
||||
return mentioned_rel_fnames
|
||||
|
||||
def check_for_file_mentions(self, content):
|
||||
mentioned_rel_fnames = self.get_file_mentions(content)
|
||||
|
||||
if not mentioned_rel_fnames:
|
||||
return
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue