You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
thrownewError(`${errorContext}String not found in file: "${oldString}"`);
15
+
}
16
+
17
+
if(replaceAll){
18
+
// Replace all occurrences using replaceAll for proper handling of special characters
19
+
returncontent.replaceAll(oldString,newString);
20
+
}else{
21
+
// Count occurrences using indexOf for proper handling of special characters
22
+
letcount=0;
23
+
letindex=content.indexOf(oldString);
24
+
while(index!==-1){
25
+
count++;
26
+
index=content.indexOf(oldString,index+1);
27
+
}
28
+
29
+
if(count>1){
30
+
thrownewError(
31
+
`${errorContext}String "${oldString}" appears ${count} times in the file. Either provide a more specific string with surrounding context to make it unique, or use replace_all=true to replace all occurrences.`,
`Edit ${editIndex+1}: String "${old_string}" appears ${occurrences} times in the file. Either provide a more specific string with surrounding context to make it unique, or use replace_all=true to replace all occurrences.`,
`String "${old_string}" appears ${occurrences} times in the file. Either provide a more specific string with surrounding context to make it unique, or use replace_all=true to replace all occurrences.`,
0 commit comments