Fix multiline partial-line suffix preservation#9623
Merged
Conversation
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>
Contributor
|
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 Powered by Oz |
Contributor
There was a problem hiding this comment.
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
kevinyang372
approved these changes
May 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
ready-to-specorready-to-implement.Screenshots / Videos
N/A — diff validation logic change.
Testing
cargo fmtcargo clippy --workspace --exclude warp_completer --all-targets --tests -- -D warningscargo clippy -p warp_completer --all-targets --tests -- -D warningscargo nextest run -p ai -E 'test(diff_validation)'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