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

This commit is contained in:
fuyou
2025-09-05 10:12:57 +08:00
committed by GitHub
parent aea6230bcc
commit 0bc0d23cb3
6 changed files with 68 additions and 23 deletions
+1 -20
View File
@@ -30,26 +30,7 @@ import {
} from './modifiable-tool.js';
import { IdeClient, IDEConnectionStatus } from '../ide/ide-client.js';
import { FixLLMEditWithInstruction } from '../utils/llm-edit-fixer.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);
}
import { applyReplacement } from './edit.js';
interface ReplacementContext {
params: EditToolParams;