@@ -4,6 +4,7 @@ import { getSettingValue } from "./settings";
44
55const TAB_TIME_COUNTERS_STORAGE_KEY = "tabTimeCounters" ;
66const ARCHIVED_TABS_STORAGE_KEY = "archivedTabs" ;
7+ const STATUS_MESSAGE_TIMEOUT_MS = 3000 ;
78
89interface TabTimeCounters {
910 [ tabGroupId : number ] : {
@@ -169,7 +170,7 @@ export const clearArchivedTabs = async (context: vscode.ExtensionContext) => {
169170 // Clear from workspace state
170171 try {
171172 await context . workspaceState . update ( ARCHIVED_TABS_STORAGE_KEY , [ ] ) ;
172- vscode . window . showInformationMessage ( "All archived tabs have been cleared." ) ;
173+ vscode . window . setStatusBarMessage ( "All archived tabs have been cleared." , STATUS_MESSAGE_TIMEOUT_MS ) ;
173174 } catch ( error : unknown ) {
174175 vscode . window . showErrorMessage ( `Failed to clear archived tabs: ${ error instanceof Error ? error . message : String ( error ) } ` ) ;
175176 }
@@ -332,35 +333,24 @@ export const closeAllDiffTabs = () => {
332333
333334 let closedCount = 0 ;
334335
335- // Create a promise that will resolve after the operation completes
336- const closeTabsPromise = new Promise < number > ( ( resolve ) => {
337- vscode . window . tabGroups . all . forEach ( ( tabGroup ) => {
338- tabGroup . tabs . forEach ( ( tab ) => {
339- // Check if this is a diff editor tab
340- if ( tab . input instanceof vscode . TabInputTextDiff ) {
341- vscode . window . tabGroups . close ( tab ) ;
342- closedCount ++ ;
343- }
344- } ) ;
336+ // Directly iterate through tab groups and close diff tabs
337+ vscode . window . tabGroups . all . forEach ( ( tabGroup ) => {
338+ tabGroup . tabs . forEach ( ( tab ) => {
339+ // Check if this is a diff editor tab
340+ if ( tab . input instanceof vscode . TabInputTextDiff ) {
341+ vscode . window . tabGroups . close ( tab ) ;
342+ closedCount ++ ;
343+ }
345344 } ) ;
346- resolve ( closedCount ) ;
347345 } ) ;
348346
349- // Create a timeout promise
350- const timeoutPromise = new Promise < number > ( ( _ , reject ) => {
351- setTimeout ( ( ) => reject ( new Error ( "Operation timed out" ) ) , 5000 ) ; // 5 second timeout
352- } ) ;
353-
354- // Race the promises
355- Promise . race ( [ closeTabsPromise , timeoutPromise ] )
356- . then ( ( count ) => {
357- if ( count > 0 ) {
358- vscode . window . showInformationMessage ( `Closed ${ count } diff tab${ count === 1 ? '' : 's' } .` ) ;
359- } else {
360- vscode . window . showInformationMessage ( 'No diff tabs found to close.' ) ;
361- }
362- } )
363- . catch ( ( error ) => {
364- vscode . window . showErrorMessage ( `Failed to close diff tabs: ${ error . message } ` ) ;
365- } ) ;
347+ // Show appropriate message based on result
348+ if ( closedCount > 0 ) {
349+ vscode . window . setStatusBarMessage (
350+ `Closed ${ closedCount } diff tab${ closedCount === 1 ? '' : 's' } .` ,
351+ STATUS_MESSAGE_TIMEOUT_MS
352+ ) ;
353+ } else {
354+ vscode . window . setStatusBarMessage ( 'No diff tabs found to close.' , STATUS_MESSAGE_TIMEOUT_MS ) ;
355+ }
366356} ;
0 commit comments