@@ -298,21 +298,24 @@ export class DiffViewProvider {
298298 await this . reset ( )
299299 }
300300
301- private async closeAllDiffViews ( ) {
302- const tabs = vscode . window . tabGroups . all
303- . flatMap ( ( tg ) => tg . tabs )
304- . filter (
305- ( tab ) =>
306- tab . input instanceof vscode . TabInputTextDiff &&
307- tab . input ?. original ?. scheme === DIFF_VIEW_URI_SCHEME ,
308- )
309-
310- for ( const tab of tabs ) {
311- // Trying to close dirty views results in save popup.
312- if ( ! tab . isDirty ) {
313- await vscode . window . tabGroups . close ( tab )
301+ private async closeAllDiffViews ( ) : Promise < void > {
302+ const closeOps = vscode . window . tabGroups . all
303+ . flatMap ( group => group . tabs )
304+ . filter (
305+ tab =>
306+ tab . input instanceof vscode . TabInputTextDiff &&
307+ tab . input . original . scheme === DIFF_VIEW_URI_SCHEME &&
308+ ! tab . isDirty
309+ )
310+ . map ( tab =>
311+ vscode . window . tabGroups . close ( tab ) . then (
312+ ( ) => undefined ,
313+ err => {
314+ console . error ( `Failed to close diff tab ${ tab . label } ` , err ) ;
314315 }
315- }
316+ ) ) ;
317+
318+ await Promise . all ( closeOps ) ;
316319 }
317320
318321 private async openDiffEditor ( ) : Promise < vscode . TextEditor > {
@@ -419,15 +422,8 @@ export class DiffViewProvider {
419422 return result
420423 }
421424
422- async reset ( ) {
423- // Ensure any diff views opened by this provider are closed to release
424- // memory.
425- try {
426- await this . closeAllDiffViews ( )
427- } catch ( error ) {
428- console . error ( "Error closing diff views" , error )
429- }
430-
425+ async reset ( ) : Promise < void > {
426+ await this . closeAllDiffViews ( )
431427 this . editType = undefined
432428 this . isEditing = false
433429 this . originalContent = undefined
0 commit comments