From 785259b59c63c72137c44a785f11a7def4680d97 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sat, 11 May 2024 10:33:46 -0700 Subject: [PATCH] try patching any of the other files in the chat --- aider/coders/editblock_coder.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/aider/coders/editblock_coder.py b/aider/coders/editblock_coder.py index 8f6582d3b..4a5c75ede 100644 --- a/aider/coders/editblock_coder.py +++ b/aider/coders/editblock_coder.py @@ -30,9 +30,17 @@ class EditBlockCoder(Coder): path, original, updated = edit full_path = self.abs_root_path(path) content = self.io.read_text(full_path) - content = do_replace(full_path, content, original, updated, self.fence) - if content: - self.io.write_text(full_path, content) + 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: + content = self.io.read_text(full_path) + new_content = do_replace(full_path, content, original, updated, self.fence) + if new_content: + break + + if new_content: + self.io.write_text(full_path, new_content) passed.append(edit) else: failed.append(edit)