fix(opencode): preserve original line endings in 'edit' tool by ranqn · Pull Request #9443 · anomalyco/opencode
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.