[Bug] diff_edit splits the SEARCH block inside a long line of "=" characters
Description
diff_edit looks for the ======= separator as a plain substring. A line such as ========== (an underline in Markdown or reStructuredText) contains it, so it is treated as the separator. The wrong text is applied and the file is damaged.
Environment
- OS: Windows 11 Home 10.0.26300
- Node version: v22.22.3
- Nanocoder version: 1.32.0 (built from main at f92cce9c)
- Provider: Not provider-specific
- Model: Not model-specific
Steps to Reproduce
-
Create
heading.rstcontainingTitle\n==========\n\nBody\nand read it withread_file. -
Call
diff_editwith this diff:<<<<<<< SEARCH Title ========== ======= New Title ========== >>>>>>> REPLACE
Expected Behavior
The file becomes New Title\n==========\n\nBody\n.
Actual Behavior
The validator says the diff is valid and the file is damaged.
Logs/Screenshots
parseDiffEditBlocks -> [{search: "Title", replace: "===\n=======\nNew Title\n=========="}]
file after: "===\n=======\nNew Title\n==========\n==========\n\nBody\n"
Additional Context
- [x] I have searched existing issues to ensure this is not a duplicate
- [x] I can reproduce this issue consistently
- [x] This issue occurs with the latest version of nanocoder (main)
Suggested fix:
source/tools/file-ops/diff-edit.tsx:100usesdiff.indexOf(SEPARATOR_MARKER, ...). Match the separator only when it is a whole line (for example/^=======$/m), and check the REPLACE marker the same way.- Add tests for underlines of 7 or more
=characters in both the search and replace parts.
I will pick this up, following the suggested whole-line marker fix. I will cover long equals underlines and marker-looking inline text in SEARCH and REPLACE, including CRLF input, and keep the existing multi-block behavior.
I'd like to work on this. #2212 was closed by its author, so I'll pick it up unless they're coming back to it.