diff options
| author | Taylor Mullen <[email protected]> | 2025-05-25 13:37:37 -0700 |
|---|---|---|
| committer | N. Taylor Mullen <[email protected]> | 2025-05-25 13:40:58 -0700 |
| commit | ceb25c8350dd21a56a1431643faf8739d026b869 (patch) | |
| tree | 50a24a88ff7b9072bbc9d6c54ed8c8af72c6b04a /packages/server/src | |
| parent | 24da7b3ca69cb4729b86dc74d43f16efa3a2ac64 (diff) | |
refactor: Decouple new_string correction from old_string
- Previously, `new_string` was assumed to be over-escaped if `old_string` was.
- This change introduces an explicit check (`newStringPotentiallyEscaped`) to determine if `new_string` itself needs correction.
- If `new_string` is potentially escaped, its corrected using an LLM call; otherwise, the original `new_string` is used.
- This avoids unnecessary corrections to `new_string` when only `old_string` was problematic.
Part of https://github.com/google-gemini/gemini-cli/issues/484
Diffstat (limited to 'packages/server/src')
| -rw-r--r-- | packages/server/src/utils/editCorrector.ts | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/packages/server/src/utils/editCorrector.ts b/packages/server/src/utils/editCorrector.ts index 5b96eb20..c8a8e1a9 100644 --- a/packages/server/src/utils/editCorrector.ts +++ b/packages/server/src/utils/editCorrector.ts @@ -78,7 +78,14 @@ export async function ensureCorrectEdit( if (occurrences === 1) { finalOldString = unescapedOldStringAttempt; - finalNewString = unescapeStringForGeminiBug(originalParams.new_string); + if (newStringPotentiallyEscaped) { + finalNewString = await correctNewString( + client, + originalParams.old_string, // original old + unescapedOldStringAttempt, // corrected old + originalParams.new_string, // original new (which is potentially escaped) + ); + } } else if (occurrences === 0) { const llmCorrectedOldString = await correctOldStringMismatch( client, |
