summaryrefslogtreecommitdiff
path: root/packages/server/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/server/src')
-rw-r--r--packages/server/src/tools/edit.ts19
1 files changed, 2 insertions, 17 deletions
diff --git a/packages/server/src/tools/edit.ts b/packages/server/src/tools/edit.ts
index 296c31ed..f7c911ec 100644
--- a/packages/server/src/tools/edit.ts
+++ b/packages/server/src/tools/edit.ts
@@ -205,8 +205,7 @@ Expectation for parameters:
};
} else {
// Successful edit calculation
- newContent = this.replaceAll(
- currentContent,
+ newContent = currentContent.replaceAll(
params.old_string,
params.new_string,
);
@@ -274,8 +273,7 @@ Expectation for parameters:
if (correctedOccurrences === 0 || correctedOccurrences !== 1) {
return false;
}
- newContent = this.replaceAll(
- currentContent,
+ newContent = currentContent.replaceAll(
params.old_string,
params.new_string,
);
@@ -393,19 +391,6 @@ Expectation for parameters:
}
/**
- * Replaces all occurrences of a substring in a string
- */
- private replaceAll(str: string, find: string, replace: string): string {
- if (find === '') {
- return str;
- }
- // Use RegExp with global flag for true replacement of all instances
- // Escape special regex characters in the find string
- const escapedFind = find.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
- return str.replace(new RegExp(escapedFind, 'g'), replace);
- }
-
- /**
* Creates parent directories if they don't exist
*/
private ensureParentDirectoriesExist(filePath: string): void {