[BUG] Edit rewrites every line ending in a file with mixed CRLF/LF, though the edit touches one line
What's Wrong?
When a file mixes CRLF and LF line endings, a one-line Edit converts every CRLF in the file to LF. The lines the edit did not touch change too. The tool reports "updated successfully" and says nothing about the line endings.
Files that use CRLF throughout keep CRLF, so this only hits mixed files (common in repos where some lines came from Windows and some from Linux, or in generated files).
This was reported as #42724 in April. It was closed as stale and locked, and the bot asked for a new issue if it is still relevant. It still happens on 2.1.295.
What Should Happen?
Only the replaced text changes. Every byte outside old_string stays as it was, including each line's own ending.
Steps to Reproduce
- Make the file (bytes shown with
od -c):
```
a = 1\r\nfruit = "APPLE"\nb = 2\r\nc = 3\n
`
bash``
printf 'a = 1\r\nfruit = "APPLE"\nb = 2\r\nc = 3\n' > mixed_eol.py
- Ask Claude to change
APPLEtoORANGEwith the Edit tool (old_string: fruit = "APPLE",new_string: fruit = "ORANGE"). - Look at the bytes:
```
a = 1\nfruit = "ORANGE"\nb = 2\nc = 3\n
\r\n
Both became \n`. Lines 1 and 3 were not part of the edit.
Control in the same session, same Edit: a file that is CRLF throughout keeps every CRLF. A UTF-8 LF file changes only the one word.
Environment
- Claude Code 2.1.295 (Claude Desktop's Code tab), Windows 11
- Reproduced with the Edit tool directly; the model and the prompt play no part
- The 2.1.296 changelog has no entry for this; I could not run 2.1.296 itself here
Related
#42724 (same report, closed as stale and locked)
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗