@@ -59,7 +59,7 @@ export class ElectronFileSystemProvider implements vscode.FileSystemProvider {
5959 throw new vscode . FileSystemError ( "Method not implemented." ) ;
6060 }
6161
62- delete ( ) : void {
62+ delete ( _uri : vscode . Uri ) : void {
6363 throw new vscode . FileSystemError ( "Method not implemented." ) ;
6464 }
6565
@@ -73,6 +73,26 @@ export class ElectronPatchFileSystemProvider extends ElectronFileSystemProvider
7373 super ( ) ;
7474 }
7575
76+ async delete ( uri : vscode . Uri ) : Promise < void > {
77+ const queryParams = new URLSearchParams ( uri . query ) ;
78+ const patchFileUri = vscode . Uri . parse ( queryParams . get ( "patch" ) ! , true ) ;
79+
80+ const patchDirectory = vscode . Uri . file ( path . dirname ( patchFileUri . fsPath ) ) ;
81+ const cwd =
82+ await this . patchesProvider . getCheckoutDirectoryForPatchDirectory (
83+ patchDirectory ,
84+ ) ;
85+
86+ // Update the file so that its start and end blob IDs are the same,
87+ // which will result in an empty diff and the file removed from the patch
88+ await this . updateFileInPatch (
89+ patchFileUri ,
90+ uri ,
91+ cwd ,
92+ queryParams . get ( "blobIdA" ) ! ,
93+ ) ;
94+ }
95+
7696 async writeFile ( uri : vscode . Uri , content : Uint8Array ) : Promise < void > {
7797 const queryParams = new URLSearchParams ( uri . query ) ;
7898 const patchFileUri = vscode . Uri . parse ( queryParams . get ( "patch" ) ! , true ) ;
@@ -88,6 +108,15 @@ export class ElectronPatchFileSystemProvider extends ElectronFileSystemProvider
88108 Buffer . from ( content ) . toString ( "utf8" ) ,
89109 ) ;
90110
111+ await this . updateFileInPatch ( patchFileUri , uri , cwd , newBlobId ) ;
112+ }
113+
114+ private async updateFileInPatch (
115+ patchFileUri : vscode . Uri ,
116+ uri : vscode . Uri ,
117+ cwd : vscode . Uri ,
118+ newBlobId : string ,
119+ ) {
91120 // Parse the existing patch file to get the metadata
92121 const patchContents = (
93122 await vscode . workspace . fs . readFile ( patchFileUri )
0 commit comments