The `edit_file` tool re-indents `new_text` by computing a single indent delta from the first line of `old_text` versus the matched buffer line, then applying that delta to every line of the replacement. When a model omits the leading indentation on only the first line of `old_text`/`new_text` (a common pattern when copying from mid-line context), the delta computed from the first line was wrongly applied to the remaining, already-correctly-indented lines, doubling their indentation. This PR: - Tracks the `(query_row, buffer_row)` line pairs aligned by the streaming fuzzy matcher so the indent of each `old_text` line can be compared against the buffer line it actually matched. - Computes a separate indent delta for the lines after the first: when those lines agree on a consistent delta, it's used for the rest of the replacement; otherwise the previous uniform behavior is preserved. - Keeps `query_lines`/line pairs in sync when `finish()` extends a match with a trailing incomplete line. - Adds an end-to-end regression test reproducing the issue, plus unit tests for the new re-indentation logic. Closes https://github.com/zed-industries/zed/issues/60302 Release Notes: - Fixed the agent's `edit_file` tool corrupting indentation when a replacement omitted leading whitespace on only its first line.
4 files changedLine totals unavailable