fix: normalize CRLF line endings in edit tool parameters#2474
Closed
Br1an67 wants to merge 1 commit intoQwenLM:mainfrom
Closed
fix: normalize CRLF line endings in edit tool parameters#2474Br1an67 wants to merge 1 commit intoQwenLM:mainfrom
Br1an67 wants to merge 1 commit intoQwenLM:mainfrom
Conversation
…arameters When old_string is provided with CRLF line endings (e.g. from a Windows IDE or LLM output), it fails to match the LF-normalized file content, causing multi-line edits to fail silently. The file content is already normalized from CRLF to LF on read (line 163), but the old_string and new_string parameters were not. This adds matching normalization for both parameters before the matching logic runs. Fixes QwenLM#2257 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Collaborator
|
This issue cannot be reproduced on Windows system, with utf-8 bom + CRLF newlines. I suspect the real edit problem is related to #1922 , which involved mixed Chinese/English character. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TLDR
Fixes the Edit tool failing on multi-line edits when
old_stringcontains CRLF (\r\n) line endings but the file content has been normalized to LF (\n). This is a one-line root cause fix plus a regression test.Dive Deeper
The Edit tool already normalizes file content from CRLF to LF on read (
edit.ts:163):However, the
old_stringandnew_stringparameters were not normalized, so when an LLM or Windows IDE providesold_stringwith CRLF line endings,indexOf()fails to find a match against the LF-normalized content. This is especially common with UTF-8 BOM + CRLF projects on Windows (as reported in #2257).The fix adds matching CRLF→LF normalization for
old_stringandnew_stringbefore the matching logic runs:Reviewer Test Plan
printf "line1\r\nline2\r\nline3" > test.txt)old_stringcontaining CRLFTesting Matrix
Linked issues / bugs
Fixes #2257