fix: make start_line and end_line parsing more lenient to accept brackets #11159
+133
−5
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.
Summary
This PR attempts to address Issue #11087. Feedback and guidance are welcome.
Problem
Some models (like MiniMax-2.1 and Gemini) send line numbers with brackets, such as
:start_line:[245]instead of:start_line:245. The current regex parsing was too strict and did not accept these variations, causing the diff to fail with "No sufficiently similar match found".Solution
Updated the regex in
MultiSearchReplaceDiffStrategyto accept optional brackets around line numbers. The regex now supports::start_line:253:start_line: 253:start_line:[253]:start_line: [253]Same support added for
:end_line:.Changes
src/core/diff/strategies/multi-search-replace.ts: Updated regex pattern to use\[?(\d+)\]?instead of(\d+)for both start_line and end_line parsingsrc/core/diff/strategies/__tests__/multi-search-replace.spec.ts: Added test cases for the new bracket variationsTesting
Fixes #11087
Important
Update
MultiSearchReplaceDiffStrategyto allow optional brackets around line numbers in diffs, with new tests added.MultiSearchReplaceDiffStrategyto accept optional brackets around line numbers for:start_line:and:end_line:.:start_line:253,:start_line: 253,:start_line:[253], and:start_line: [253].multi-search-replace.spec.tsfor bracket variations in line numbers.This description was created by
for 30c730f. You can customize this summary. It will automatically update as commits are pushed.