SIGN IN SIGN UP

fix: preserve indentation when applying code edits to Python files (#11289)

* fix: preserve indentation when applying code edits via fuzzy matching

When fallback matching strategies (trimmedMatch, whitespaceIgnoredMatch)
find a match with different indentation than the LLM-provided old_string,
the replacement new_string now has its indentation adjusted to match the
actual indentation level in the file. This fixes incorrect indentation in
Python code edits where the LLM provides unindented search/replace strings
that match indented code blocks.

Fixes #11282

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(core): adjust indentation when fallback match strategies splice replacements

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
M
Matt Van Horn committed
9c08e5917a1196da847b41c1996e39e3badf3307
Parent: 4714bae
Committed by GitHub <noreply@github.com> on 3/24/2026, 8:12:00 PM