From 9e548988666c5ce1bcc81e74197b5c2284e5bf86 Mon Sep 17 00:00:00 2001 From: zjy1412 Date: Thu, 17 Apr 2025 14:30:13 +0800 Subject: [PATCH] fix: correctly detect edit blocks in diff-fenced mode --- aider/coders/editblock_coder.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/aider/coders/editblock_coder.py b/aider/coders/editblock_coder.py index 321a6a921..4d7776278 100644 --- a/aider/coders/editblock_coder.py +++ b/aider/coders/editblock_coder.py @@ -454,7 +454,10 @@ def find_original_update_blocks(content, fence=DEFAULT_FENCE, valid_fnames=None) "```csh", "```tcsh", ] - next_is_editblock = i + 1 < len(lines) and head_pattern.match(lines[i + 1].strip()) + + # Check if the next line or the one after that is an editblock + next_is_editblock = (i + 1 < len(lines) and head_pattern.match(lines[i + 1].strip()) + or i + 2 < len(lines) and head_pattern.match(lines[i + 2].strip())) if any(line.strip().startswith(start) for start in shell_starts) and not next_is_editblock: shell_content = []