Skip to content

Fix multiline partial-line suffix preservation#9623

Merged
szgupta merged 2 commits into
masterfrom
suraj/fix-multiline-suffix-preservation
May 12, 2026
Merged

Fix multiline partial-line suffix preservation#9623
szgupta merged 2 commits into
masterfrom
suraj/fix-multiline-suffix-preservation

Conversation

@szgupta
Copy link
Copy Markdown
Member

@szgupta szgupta commented Apr 30, 2026

Description

Fix diff validation for search/replace edits whose final search line is a partial prefix of the matched file line when the replacement deletes earlier lines.

Previously suffix preservation only ran when the search and replacement had the same line count. That missed cases where the model kept a partial trailing context line, but removed middle lines, causing the unchanged suffix of the final matched file line to be dropped. This adds a helper that preserves the final-line suffix when the replacement's final line carries the same partial context, and keeps the existing same-line-count behavior.

Linked Issue

N/A — follow-up regression from Agent Mode diff application behavior.

  • The linked issue is labeled ready-to-spec or ready-to-implement.
  • Where appropriate, screenshots or a short video of the implementation are included below (especially for user-visible or UI changes).

Screenshots / Videos

N/A — diff validation logic change.

Testing

  • cargo fmt
  • cargo clippy --workspace --exclude warp_completer --all-targets --tests -- -D warnings
  • cargo clippy -p warp_completer --all-targets --tests -- -D warnings
  • cargo nextest run -p ai -E 'test(diff_validation)'

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

Oz conversation

CHANGELOG-BUG-FIX: Fixed file edit diffs dropping the end of a partial trailing context line when applying multi-line replacements.

Co-Authored-By: Oz oz-agent@warp.dev

Preserve unmatched final-line suffixes when a replacement removes earlier lines but retains a partial trailing context line.

Co-Authored-By: Oz <oz-agent@warp.dev>
@cla-bot cla-bot Bot added the cla-signed label Apr 30, 2026
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented Apr 30, 2026

@szgupta

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and posted feedback on this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview

This PR refactors partial-line suffix preservation into a helper and extends it to multi-line replacements that delete earlier lines while retaining the final partial context line. It also adds a regression test covering the dropped-suffix case.

Concerns

  • No blocking correctness concerns found in the changed lines.
  • Security pass: no security-sensitive behavior or new trust boundary was introduced by this string-preservation logic.

Verdict

Found: 0 critical, 0 important, 0 suggestions

Approve

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@szgupta szgupta requested a review from kevinyang372 May 4, 2026 16:59
@szgupta szgupta enabled auto-merge (squash) May 12, 2026 21:14
@szgupta szgupta merged commit a1b76c2 into master May 12, 2026
24 of 25 checks passed
@szgupta szgupta deleted the suraj/fix-multiline-suffix-preservation branch May 12, 2026 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants