mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 22:21:22 -07:00
fix(core): add uniqueness guard to edit tool (#19890)
Co-authored-by: Bryan Morgan <bryanmorgan@google.com>
This commit is contained in:
@@ -138,6 +138,17 @@ async function calculateExactReplacement(
|
||||
const normalizedReplace = new_string.replace(/\r\n/g, '\n');
|
||||
|
||||
const exactOccurrences = normalizedCode.split(normalizedSearch).length - 1;
|
||||
const expectedReplacements = params.expected_replacements ?? 1;
|
||||
|
||||
if (exactOccurrences > expectedReplacements) {
|
||||
return {
|
||||
newContent: currentContent,
|
||||
occurrences: exactOccurrences,
|
||||
finalOldString: normalizedSearch,
|
||||
finalNewString: normalizedReplace,
|
||||
};
|
||||
}
|
||||
|
||||
if (exactOccurrences > 0) {
|
||||
let modifiedCode = safeLiteralReplace(
|
||||
normalizedCode,
|
||||
|
||||
Reference in New Issue
Block a user