Revert "Fix dollar sign replacement bug in file editing (#7703)" (#7823)

This commit is contained in:
Gal Zahavi
2025-09-05 13:34:02 -07:00
committed by GitHub
parent 20d0de74e1
commit 0e284457be
6 changed files with 23 additions and 68 deletions
+20 -1
View File
@@ -30,7 +30,26 @@ import {
} from './modifiable-tool.js';
import { IdeClient, IDEConnectionStatus } from '../ide/ide-client.js';
import { FixLLMEditWithInstruction } from '../utils/llm-edit-fixer.js';
import { applyReplacement } from './edit.js';
export function applyReplacement(
currentContent: string | null,
oldString: string,
newString: string,
isNewFile: boolean,
): string {
if (isNewFile) {
return newString;
}
if (currentContent === null) {
// Should not happen if not a new file, but defensively return empty or newString if oldString is also empty
return oldString === '' ? newString : '';
}
// If oldString is empty and it's not a new file, do not modify the content.
if (oldString === '' && !isNewFile) {
return currentContent;
}
return currentContent.replaceAll(oldString, newString);
}
interface ReplacementContext {
params: EditToolParams;