Refactor: Use do_replace in PatchFlexCoder instead of flexible_search

This commit is contained in:
Paul Gauthier (aider) 2025-04-14 15:32:22 -07:00
parent 14928727eb
commit c68cade9f2

View file

@ -10,8 +10,8 @@ from ..dump import dump # noqa: F401
from .base_coder import Coder from .base_coder import Coder
from .patch_prompts import PatchPrompts from .patch_prompts import PatchPrompts
# Import search_replace utilities # Import do_replace from editblock_coder
from .search_replace import editblock_strategies, flexible_search_and_replace from .editblock_coder import do_replace
# Remove original PatchCoder domain objects and helpers if they exist at the top. # Remove original PatchCoder domain objects and helpers if they exist at the top.
# We will redefine or replace these as needed. # 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})..." f" Applying hunk {i + 1} (from patch line {edit.patch_line_num})..."
) )
texts = (edit.search_text, edit.replace_text, current_content) # Replace the call to flexible_search_and_replace with do_replace
new_content = flexible_search_and_replace(texts, editblock_strategies) 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: if new_content is None:
edit_failed = True edit_failed = True