fix: handle updated edits array in apply_edits return value

This commit is contained in:
Paul Gauthier 2024-10-29 14:10:19 -07:00 committed by Paul Gauthier (aider)
parent eb9a73bdb0
commit f9604633e6
2 changed files with 4 additions and 1 deletions

View file

@ -1812,6 +1812,8 @@ class Coder:
try:
edits = self.get_edits()
edits = self.prepare_to_edit(edits)
# ai: handle the case where apply_edits returns an updated edits array (it may just return None, meaning use the existing edits array)!
edited = set(edit[0] for edit in edits)
self.apply_edits(edits)
except ValueError as err:

View file

@ -50,6 +50,7 @@ class EditBlockCoder(Coder):
content = self.io.read_text(full_path)
new_content = do_replace(full_path, content, original, updated, self.fence)
if new_content:
# ai: update the edits array to reflect the actually edited file
break
if new_content:
@ -59,7 +60,7 @@ class EditBlockCoder(Coder):
failed.append(edit)
if not failed:
return
return # ai: return the updated list of edits
blocks = "block" if len(failed) == 1 else "blocks"