From 758979e4f317c8b204a411a72a95b123b5f83d77 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Mon, 14 Apr 2025 21:27:06 -0700 Subject: [PATCH] fix: Handle git diff prefixes in udiff file paths correctly --- aider/coders/udiff_coder.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/aider/coders/udiff_coder.py b/aider/coders/udiff_coder.py index 9b5b47c68..4c89af7c4 100644 --- a/aider/coders/udiff_coder.py +++ b/aider/coders/udiff_coder.py @@ -344,11 +344,16 @@ def process_fenced_block(lines, start_line_num): if block[0].startswith("--- ") and block[1].startswith("+++ "): # Extract the file path, considering that it might contain spaces - a_fname = block[1][4:].strip() + a_fname = block[0][4:].strip() b_fname = block[1][4:].strip() - # if a_fname starts with a/ and b_fname starts with b/, strip b/ ai! - fname = b_fname + # Check if standard git diff prefixes are present and strip them + if a_fname.startswith("a/") and b_fname.startswith("b/"): + fname = b_fname[2:] + else: + # Otherwise, assume the path is as intended + fname = b_fname + block = block[2:] else: fname = None