You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] string_replace fails multi-line edits on CRLF files and writes mixed line endings #1930
string_replace compares old_str with the raw file text. Models send LF, so a multi-line edit on a CRLF file is not found. A single-line edit that adds lines writes LF into a CRLF file.
Steps to reproduce
Create a.txt containing one\r\ntwo\r\nthree\r\n.
Call string_replace with old_str: "one\ntwo" and new_str: "ONE\nTWO".
Create b.txt with the same content. Call string_replace with old_str: "two" and new_str: "TWO\nTWO-b".
Expected behaviour
a.txt becomes ONE\r\nTWO\r\nthree\r\n.
b.txt becomes one\r\nTWO\r\nTWO-b\r\nthree\r\n.
Actual behaviour
The edit is refused with Content not found in file and "status":"no_candidate", and nothing is written.
read_file returns the CRLF text unchanged, so the model sees \r it cannot easily reproduce. Any Windows checkout with core.autocrlf=true has CRLF files.
Environment
Windows 11, Node v22.22.3, Nanocoder 1.31.0 (main at 948a4e7)
Suggested fix
source/tools/file-ops/string-replace.tsx:89: detect the file's dominant line ending. Match old_str after converting it to that ending, instead of an exact split(old_str).
Line 106: convert new_str to the same ending before replaceFirstLiteral.
Mention line endings in the edit-recovery evidence (source/utils/edit-recovery.ts).
Hi @addyCooks, you offered me this one on #1722, so I'm picking it up. The fix is in #1961: old_str and new_str are converted to the file's line ending when most of its lines use CRLF. Could you assign it to me? Thanks.
Hey @Mahdi-Hasan , assigning this to you, and I’ll review it this time.
For future issues, please comment first and wait to be assigned before opening a PR.
Thanks!
Activity
Mahdi-Hasan commentedon Nov 5, 2026
Hi @addyCooks, you offered me this one on #1722, so I'm picking it up. The fix is in #1961:
old_strandnew_strare converted to the file's line ending when most of its lines use CRLF. Could you assign it to me? Thanks.addyCooks commentedon Nov 5, 2026
Hey @Mahdi-Hasan , assigning this to you, and I’ll review it this time.
For future issues, please comment first and wait to be assigned before opening a PR.
Thanks!
fix(tools): match and keep CRLF line endings in string_replace (#1961)
fix(tools): match and keep CRLF line endings in string_replace (Nano-…