diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index 5ceea559f..4e9adbf3b 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -532,6 +532,7 @@ class Coder: edited, edit_error = self.apply_updates() if edit_error: + self.update_cur_messages(content, set()) return edit_error # TODO: this shouldn't use content, should use self.partial_.... @@ -1006,7 +1007,7 @@ class Coder: apply_update_errors = 0 def apply_updates(self): - max_apply_update_errors = 2 + max_apply_update_errors = 3 try: edited = self.update_files() diff --git a/aider/coders/editblock_coder.py b/aider/coders/editblock_coder.py index ee0ffa666..df29c330f 100644 --- a/aider/coders/editblock_coder.py +++ b/aider/coders/editblock_coder.py @@ -32,7 +32,17 @@ class EditBlockCoder(Coder): self.io.write_text(full_path, content) edited.add(path) continue - self.io.tool_error(f"Failed to apply edit to {path}") + raise ValueError(f"""InvalidEditBlock: edit failed! + +{path} does not contain the *exact sequence* of ORIGINAL lines you specified. +Try again. +DO NOT skip blank lines, comments, docstrings, etc! +The ORIGINAL block needs to be EXACTLY the same as the lines in {path} with nothing missing! + +{path} does not contain these {len(original.splitlines())} exact lines in a row: +``` +{original}``` +""") return edited diff --git a/aider/coders/editblock_prompts.py b/aider/coders/editblock_prompts.py index 5b9d8ce9b..7eb8ab0d0 100644 --- a/aider/coders/editblock_prompts.py +++ b/aider/coders/editblock_prompts.py @@ -33,7 +33,7 @@ some/dir/example.py Every *edit block* must be fenced with {fence[0]}...{fence[1]} with the correct code language. Every *edit block* must start with the full path! *NEVER* propose edit blocks for *read-only* files. -The ORIGINAL section must be an *exact* set of lines from the file: +The ORIGINAL section must be an *exact set of sequential lines* from the file: - NEVER SKIP LINES! - Include all original leading spaces and indentation!