[PR #9443] fix(opencode): preserve original line endings in 'edit' tool #13111

Open
opened 2026-02-16 18:17:59 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/9443

State: open
Merged: No


What does this PR do?

Fixes #2016 : The issue was closed but only the diff view was fixed back then, this PR actually fixed the root problem, which happens a lot on Windows when editing CRLF files, resulting in files with mixed line endings.

On editing CRLF files, the problem also causes an extra blank line being inserted if an edit's newString ends with a new line (\n). Sometimes an agent gets stuck in a loop to fix the extra new line, wasting a lot of tokens.

How did you verify your code works?

  • Added new edit tool tests to verify different line ending combinations.
  • Verified in a local build, mixed line endings and extra new lines are gone.
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/9443 **State:** open **Merged:** No --- ### What does this PR do? Fixes #2016 : The issue was closed but only the diff view was fixed back then, this PR actually fixed the root problem, which happens a lot on Windows when editing CRLF files, resulting in files with mixed line endings. On editing CRLF files, the problem also causes an extra blank line being inserted if an edit's `newString` ends with a new line (`\n`). Sometimes an agent gets stuck in a loop to fix the extra new line, wasting a lot of tokens. ### How did you verify your code works? - Added new edit tool tests to verify different line ending combinations. - Verified in a local build, mixed line endings and extra new lines are gone.
yindo added the pull-request label 2026-02-16 18:17:59 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13111