You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Edit tool strips all leading whitespace from matched lines (space-indented Python files) #24549
The Edit tool strips ALL leading whitespace from lines in the oldString/newString match, flattening them to column 0. The diff output shows correct indentation, but the actual file on disk has zero indentation on the edited lines. This makes the tool unusable for any edit inside indented blocks (functions, classes, if/try/for blocks, etc.).
Reproduction
Have a Python file with space-indented code inside a try block:
assertcs.temp_storage_pathisnotNone# Updates storage_path to point to the new file
Use Edit tool with oldString/newString that includes the 8-space indentation:
oldString: " assert cs.temp_storage_path is not None\n # Updates storage_path to point to the new file"
newString: " assert cs.temp_storage_path is not None\n assert cs.content_hash is not None\n # Updates storage_path to point to the new file"
Tool reports "Edit applied successfully"
File on disk has zero indentation:
assertcs.temp_storage_pathisnotNoneassertcs.content_hashisnotNone# Updates storage_path to point to the new file
This breaks Python syntax (try block without except)
Verification
cat -An confirms the edited lines have 0 leading spaces instead of 8
Activity
saintd commentedon Apr 27, 2026
Filed in error. The Edit tool preserves indentation correctly — the issue was user error (miscounting leading spaces in the oldString match). Closing.