mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-26 15:25:00 +00:00
refactor: Improve edit handling with dry run and path resolution
This commit is contained in:
parent
5b6be29c1c
commit
e1d55c82b1
2 changed files with 10 additions and 7 deletions
|
@ -1811,12 +1811,11 @@ class Coder:
|
|||
edited = set()
|
||||
try:
|
||||
edits = self.get_edits()
|
||||
edits = self.apply_edits_dry_run(edits)
|
||||
edits = self.prepare_to_edit(edits)
|
||||
|
||||
updated_edits = self.apply_edits(edits)
|
||||
if updated_edits is not None:
|
||||
edits = updated_edits
|
||||
edited = set(edit[0] for edit in edits)
|
||||
|
||||
self.apply_edits(edits)
|
||||
except ValueError as err:
|
||||
self.num_malformed_responses += 1
|
||||
|
||||
|
@ -1943,6 +1942,9 @@ class Coder:
|
|||
def apply_edits(self, edits):
|
||||
return
|
||||
|
||||
def apply_edits_dry_run(self, edits):
|
||||
return edits
|
||||
|
||||
def run_shell_commands(self):
|
||||
if not self.suggest_shell_commands:
|
||||
return ""
|
||||
|
|
|
@ -41,7 +41,7 @@ class EditBlockCoder(Coder):
|
|||
def apply_edits(self, edits, dry_run=False):
|
||||
failed = []
|
||||
passed = []
|
||||
updated = []
|
||||
updated_edits = []
|
||||
|
||||
for edit in edits:
|
||||
path, original, updated = edit
|
||||
|
@ -54,9 +54,10 @@ class EditBlockCoder(Coder):
|
|||
content = self.io.read_text(full_path)
|
||||
new_content = do_replace(full_path, content, original, updated, self.fence)
|
||||
if new_content:
|
||||
path = self.get_rel_fname(full_path)
|
||||
break
|
||||
|
||||
updated.append((path, original, updated))
|
||||
updated_edits.append((path, original, updated))
|
||||
|
||||
if new_content:
|
||||
if not dry_run:
|
||||
|
@ -66,7 +67,7 @@ class EditBlockCoder(Coder):
|
|||
failed.append(edit)
|
||||
|
||||
if dry_run:
|
||||
return updated
|
||||
return updated_edits
|
||||
|
||||
if not failed:
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue