@@ -362,3 +362,48 @@ export const closeAllDiffTabs = () => {
362362 vscode . window . setStatusBarMessage ( 'No diff tabs found to close.' , STATUS_MESSAGE_TIMEOUT_MS ) ;
363363 }
364364} ;
365+
366+ export const closeAllDeletedFiles = async ( ) => {
367+ lg ( "Closing all deleted files..." ) ;
368+
369+ let closedCount = 0 ;
370+
371+ // Directly iterate through tab groups and close tabs with deleted files
372+ for ( const tabGroup of vscode . window . tabGroups . all ) {
373+ for ( const tab of tabGroup . tabs ) {
374+ // Check if this is a text editor tab
375+ if ( tab . input instanceof vscode . TabInputText ) {
376+ const uri = tab . input . uri ;
377+
378+ // Skip untitled files
379+ if ( uri . scheme === 'untitled' ) {
380+ continue ;
381+ }
382+
383+ try {
384+ // Check if the file exists
385+ const stat = await vscode . workspace . fs . stat ( uri ) ;
386+ if ( ! stat ) {
387+ // File doesn't exist, close the tab
388+ vscode . window . tabGroups . close ( tab ) ;
389+ closedCount ++ ;
390+ }
391+ } catch ( error ) {
392+ // If we can't stat the file, it likely doesn't exist
393+ vscode . window . tabGroups . close ( tab ) ;
394+ closedCount ++ ;
395+ }
396+ }
397+ }
398+ }
399+
400+ // Show appropriate message based on result
401+ if ( closedCount > 0 ) {
402+ vscode . window . setStatusBarMessage (
403+ `Closed ${ closedCount } deleted file tab${ closedCount === 1 ? '' : 's' } .` ,
404+ STATUS_MESSAGE_TIMEOUT_MS
405+ ) ;
406+ } else {
407+ vscode . window . setStatusBarMessage ( 'No deleted file tabs found to close.' , STATUS_MESSAGE_TIMEOUT_MS ) ;
408+ }
409+ } ;
0 commit comments