Read and write files through Zed (#6169)

Co-authored-by: Agus Zubiaga <agus@zed.dev>
This commit is contained in:
Conrad Irwin
2025-08-18 16:29:45 -06:00
committed by GitHub
parent 4394b6ab4f
commit fb3ceb0da4
17 changed files with 268 additions and 50 deletions

View File

@@ -80,7 +80,9 @@ export async function getCorrectedFileContent(
let correctedContent = proposedContent;
try {
originalContent = fs.readFileSync(filePath, 'utf8');
originalContent = await config
.getFileSystemService()
.readTextFile(filePath);
fileExists = true; // File exists and was read
} catch (err) {
if (isNodeError(err) && err.code === 'ENOENT') {
@@ -261,7 +263,9 @@ class WriteFileToolInvocation extends BaseToolInvocation<
fs.mkdirSync(dirName, { recursive: true });
}
fs.writeFileSync(file_path, fileContent, 'utf8');
await this.config
.getFileSystemService()
.writeTextFile(file_path, fileContent);
// Generate diff for display result
const fileName = path.basename(file_path);