fix: handle empty original content when creating new files

This commit is contained in:
Paul Gauthier 2024-11-05 09:14:01 -08:00 committed by Paul Gauthier (aider)
parent 85f23b3408
commit c71a92ac84
2 changed files with 44 additions and 1 deletions

View file

@ -52,7 +52,10 @@ class EditBlockCoder(Coder):
content = self.io.read_text(full_path)
new_content = do_replace(full_path, content, original, updated, self.fence)
if not new_content:
# If the edit failed, and
# this is not a "create a new file" with an empty original...
# https://github.com/Aider-AI/aider/issues/2258
if not new_content and original.strip():
# try patching any of the other files in the chat
for full_path in self.abs_fnames:
content = self.io.read_text(full_path)