From c68cade9f2f5f09c45f0d59c994e9735dcb21f3a Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Mon, 14 Apr 2025 15:32:22 -0700 Subject: [PATCH] Refactor: Use do_replace in PatchFlexCoder instead of flexible_search --- aider/coders/patch_flex_coder.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/aider/coders/patch_flex_coder.py b/aider/coders/patch_flex_coder.py index c8fd0ee98..925e8ee3e 100644 --- a/aider/coders/patch_flex_coder.py +++ b/aider/coders/patch_flex_coder.py @@ -10,8 +10,8 @@ from ..dump import dump # noqa: F401 from .base_coder import Coder from .patch_prompts import PatchPrompts -# Import search_replace utilities -from .search_replace import editblock_strategies, flexible_search_and_replace +# Import do_replace from editblock_coder +from .editblock_coder import do_replace # Remove original PatchCoder domain objects and helpers if they exist at the top. # We will redefine or replace these as needed. @@ -514,8 +514,14 @@ class PatchFlexCoder(Coder): # Rename class f" Applying hunk {i + 1} (from patch line {edit.patch_line_num})..." ) - texts = (edit.search_text, edit.replace_text, current_content) - new_content = flexible_search_and_replace(texts, editblock_strategies) + # Replace the call to flexible_search_and_replace with do_replace + new_content = do_replace( + full_path, # Pass the full path as fname + current_content, + edit.search_text, + edit.replace_text, + self.fence, # Use the coder's fence attribute + ) if new_content is None: edit_failed = True