2572
return undefined;
2573
}
2575
>
const fileUri = URI.file(filePath);
2576
>
const fileUriStr = fileUri.toString();
2577
>
2578
>
let beforeExists = false;
2579
>
try {
2580
>
beforeExists = await this._fileService.exists(fileUri);
2581
>
} catch (err) {
2582
this._logService.warn(`[Copilot:${this.sessionId}] Failed to check file for edit preview: ${filePath}`, err);
2583
}
2585
>
const afterUri = buildPendingEditContentUri(this._storageUri.toString(), toolCallId, filePath);
2586
>
try {
2587
>
await this._fileService.writeFile(afterUri, VSBuffer.fromString(newFileContents));
2588
>
} catch (err) {
2589
this._logService.warn(`[Copilot:${this.sessionId}] Failed to write pending edit content for ${filePath}`, err);
2590
return undefined;
2591
}
2593
>
// If the request was already resolved (aborted/disposed) while we
2594
>
// were awaiting the write, drop the in-memory entry immediately;
2595
>
// `_deletePendingEditContent` has already run and won't run again.
2596
>
if (!this._pendingPermissions.has(toolCallId)) {
2597
this._fileService.del(afterUri).catch(err => {
2598
this._logService.warn(`[Copilot:${this.sessionId}] Failed to delete orphaned pending edit content: ${afterUri.toString()}`, err);