Repository navigation
Conversation
diff_edit matched SEARCH blocks literally against the raw file, so a multi-line block with LF breaks never matched a CRLF file and its replacement wrote LF lines back into it. Parsed blocks are now fitted with fitEditToLineEndings before validation, application and the VS Code preview, the same way string_replace does it. A block that only matches an LF region of a mixed file is still applied as sent.
nc-review: needs work — 1 blocking, 1 nit@Edzard9 — there is a blocking item below. The change fits diff_edit's SEARCH/REPLACE blocks to the file's dominant line endings with the existing
🔴 blocking · This is a duplicate of open PR #1994 ("fix(diff-edit): match SEARCH blocks on CRLF files", author Chavaaa). The evidence is strong rather than circumstantial:
Per the base rubric a duplicate of another open PR is blocking, and per the project rubric this is exactly where duplicates cluster in Nanocoder's queue. The fix is to coordinate with the other contributor: if #1994 is the one that will land, close this one; if this one is preferred (it does reuse the shared ⚪ nit · The changeset ends with 🔴 blocking · 🟠 a reviewer would ask for a change · ⚪ optional Automated code review — correctness, security, design, tests, plus duplicates and scope. A human still decides; this is not a substitute for review and is not exhaustive. The required status checks separately cover lint, formatting, types, unused dependencies, the test suite and the build. This bot never merges. Maintainers can rerun with |
|
Hi, thanks for the review. Noting the timeline here for the maintainers: I claimed issue #1993 in a comment on the issue itself before opening this PR, and followed the approach the issue points to - reusing fitEditToLineEndings from #1961 rather than reimplementing the matching, applied in the executor, the validator, and the VS Code diff preview, with regression tests for both the CRLF and mixed-ending cases. I see #1994 by @chavaAA tackles the same issue and was opened just before this one. Happy to defer to whichever the maintainers prefer - if #1994 is the one you'd rather land, I'll close this PR with no hard feelings. If this one is preferred, I can keep it updated. Either way #1993 should end up closed by one of them; I've added the closing keyword to this PR's description as the review suggested. |
|
Understood, thanks for clarifying. Closing this PR. I'll comment and wait for assignment before opening a PR next time. Good luck @Mahdi-Hasan! |
Description
diff_editmatched SEARCH blocks literally against the raw file content, so a multi-line block sent with LF line breaks never matched a file with CRLF line endings, and was refused withSearch block 1 was not found in file.Parsed blocks are now fitted to the file's line endings with
fitEditToLineEndingsfromsource/utils/line-endings.ts- the same helperstring_replaceuses since #1961 - before validation, application, and the VS Code diff preview. When most of a file's lines end in CRLF, the search and replacement text are converted to CRLF; LF files are unchanged, and a block that only matches an LF region of a mixed file is applied as sent.I commented on #1993 first that I would like to take it. This is the third and last file editor from #1964 with the CRLF problem, after
string_replace(#1961) andwrite_file(#1992).Closes #1993
Type of Change
Changeset
pnpm changeset) describing this change for the changelogTesting
Automated Tests
.spec.ts/tsxfilespnpm test:allcompletes successfully)Added two tests to
diff-edit.spec.tsx: a multi-line LF SEARCH block against a CRLF file (the result keeps CRLF endings everywhere), and a mixed-ending file where the LF search only matches the LF region and is applied as sent. Ran locally:diff-edit.spec.tsx(33 tests),line-endings.spec.tsandstring-replace.spec.tsx(67 tests) all pass, andpnpm test:typesis clean. The fullpnpm test:allsuite was left to CI.Manual Testing
Not applicable: this only changes how the local
diff_edittool matches text in files, independent of provider.Checklist
On the two unchecked boxes: I am not formally assigned to #1993 (I left a comment on the issue stating I would work on it), and this change adds no new behavior that needs logging.