From 966a613ffed5eb591b856066990f512c9d0d5917 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Mon, 4 Nov 2024 09:07:47 -0800 Subject: [PATCH] fix: handle non-existent files in EditBlockCoder #2233 --- aider/coders/editblock_coder.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/aider/coders/editblock_coder.py b/aider/coders/editblock_coder.py index 97b913c59..316205e72 100644 --- a/aider/coders/editblock_coder.py +++ b/aider/coders/editblock_coder.py @@ -46,8 +46,12 @@ class EditBlockCoder(Coder): for edit in edits: path, original, updated = edit full_path = self.abs_root_path(path) - content = self.io.read_text(full_path) - new_content = do_replace(full_path, content, original, updated, self.fence) + new_content = None + + if Path(full_path).exists(): + content = self.io.read_text(full_path) + new_content = do_replace(full_path, content, original, updated, self.fence) + if not new_content: # try patching any of the other files in the chat for full_path in self.abs_fnames: