mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-24 03:54:43 -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 normalizedReplace = new_string.replace(/\r\n/g, '\n');
|
||||||
|
|
||||||
const exactOccurrences = normalizedCode.split(normalizedSearch).length - 1;
|
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) {
|
if (exactOccurrences > 0) {
|
||||||
let modifiedCode = safeLiteralReplace(
|
let modifiedCode = safeLiteralReplace(
|
||||||
normalizedCode,
|
normalizedCode,
|
||||||
|
|||||||
Reference in New Issue
Block a user