@@ -10,7 +10,7 @@ import { setFileNameComparer } from 'vs/base/common/comparers';
1010import { IDisposable , dispose , Disposable } from 'vs/base/common/lifecycle' ;
1111import { Event , Emitter , setGlobalLeakWarningThreshold } from 'vs/base/common/event' ;
1212import { EventType , addDisposableListener , addClasses , addClass , removeClass , isAncestor , getClientArea , position , size , removeClasses } from 'vs/base/browser/dom' ;
13- import { RunOnceScheduler , runWhenIdle , IdleValue } from 'vs/base/common/async' ;
13+ import { runWhenIdle , IdleValue } from 'vs/base/common/async' ;
1414import { getZoomLevel , onDidChangeFullscreen , isFullscreen , getZoomFactor } from 'vs/base/browser/browser' ;
1515import { mark } from 'vs/base/common/performance' ;
1616import { onUnexpectedError , setUnexpectedErrorHandler } from 'vs/base/common/errors' ;
@@ -71,7 +71,6 @@ import { IWorkspaceEditingService } from 'vs/workbench/services/workspace/common
7171import { FileDecorationsService } from 'vs/workbench/services/decorations/browser/decorationsService' ;
7272import { IDecorationsService } from 'vs/workbench/services/decorations/browser/decorations' ;
7373import { ActivityService } from 'vs/workbench/services/activity/browser/activityService' ;
74- import { URI } from 'vs/base/common/uri' ;
7574import { IListService , ListService } from 'vs/platform/list/browser/listService' ;
7675import { IViewsService } from 'vs/workbench/common/views' ;
7776import { ViewsService } from 'vs/workbench/browser/parts/views/views' ;
@@ -241,7 +240,6 @@ export class Workbench extends Disposable implements IPartService {
241240 private static readonly sidebarPositionConfigurationKey = 'workbench.sideBar.location' ;
242241 private static readonly statusbarVisibleConfigurationKey = 'workbench.statusBar.visible' ;
243242 private static readonly activityBarVisibleConfigurationKey = 'workbench.activityBar.visible' ;
244- private static readonly closeWhenEmptyConfigurationKey = 'window.closeWhenEmpty' ;
245243 private static readonly fontAliasingConfigurationKey = 'workbench.fontAliasing' ;
246244
247245 _serviceBrand : any ;
@@ -316,8 +314,6 @@ export class Workbench extends Disposable implements IPartService {
316314 private inZenModeContext : IContextKey < boolean > ;
317315 private sideBarVisibleContext : IContextKey < boolean > ;
318316
319- private closeEmptyWindowScheduler : RunOnceScheduler = this . _register ( new RunOnceScheduler ( ( ) => this . onAllEditorsClosed ( ) , 50 ) ) ;
320-
321317 constructor (
322318 private container : HTMLElement ,
323319 private configuration : IWindowConfiguration ,
@@ -453,10 +449,7 @@ export class Workbench extends Disposable implements IPartService {
453449 this . layout ( ) ;
454450
455451 // Handle case where workbench is not starting up properly
456- const timeoutHandle = setTimeout ( ( ) => {
457- this . logService . warn ( 'Workbench did not finish loading in 10 seconds, that might be a problem that should be reported.' ) ;
458- } , 10000 ) ;
459-
452+ const timeoutHandle = setTimeout ( ( ) => this . logService . warn ( 'Workbench did not finish loading in 10 seconds, that might be a problem that should be reported.' ) , 10000 ) ;
460453 this . lifecycleService . when ( LifecyclePhase . Restored ) . then ( ( ) => clearTimeout ( timeoutHandle ) ) ;
461454
462455 // Restore Parts
@@ -776,21 +769,9 @@ export class Workbench extends Disposable implements IPartService {
776769 // Storage
777770 this . _register ( this . storageService . onWillSaveState ( e => this . saveState ( e ) ) ) ;
778771
779- // Listen to visible editor changes
780- this . _register ( this . editorService . onDidVisibleEditorsChange ( ( ) => this . onDidVisibleEditorsChange ( ) ) ) ;
781-
782- // Listen to editor group activations when editor is hidden
783- this . _register ( this . editorPart . onDidActivateGroup ( ( ) => { if ( this . editorHidden ) { this . setEditorHidden ( false ) ; } } ) ) ;
784-
785- // Listen to editor closing (if we run with --wait)
786- const filesToWait = this . configuration . filesToWait ;
787- if ( filesToWait ) {
788- const resourcesToWaitFor = filesToWait . paths . map ( p => p . fileUri ) ;
789- const waitMarkerFile = URI . file ( filesToWait . waitMarkerFilePath ) ;
790- const listenerDispose = this . editorService . onDidCloseEditor ( ( ) => this . onEditorClosed ( listenerDispose , resourcesToWaitFor , waitMarkerFile ) ) ;
791-
792- this . _register ( listenerDispose ) ;
793- }
772+ // Restore editor if hidden and it changes
773+ this . _register ( this . editorService . onDidVisibleEditorsChange ( ( ) => this . restoreHiddenEditor ( ) ) ) ;
774+ this . _register ( this . editorPart . onDidActivateGroup ( ( ) => this . restoreHiddenEditor ( ) ) ) ;
794775
795776 // Configuration changes
796777 this . _register ( this . configurationService . onDidChangeConfiguration ( ( ) => this . onDidUpdateConfiguration ( ) ) ) ;
@@ -837,42 +818,12 @@ export class Workbench extends Disposable implements IPartService {
837818 }
838819 }
839820
840- private onEditorClosed ( listenerDispose : IDisposable , resourcesToWaitFor : URI [ ] , waitMarkerFile : URI ) : void {
841-
842- // In wait mode, listen to changes to the editors and wait until the files
843- // are closed that the user wants to wait for. When this happens we delete
844- // the wait marker file to signal to the outside that editing is done.
845- if ( resourcesToWaitFor . every ( resource => ! this . editorService . isOpen ( { resource } ) ) ) {
846- listenerDispose . dispose ( ) ;
847- this . fileService . del ( waitMarkerFile ) ;
848- }
849- }
850-
851- private onDidVisibleEditorsChange ( ) : void {
852- const visibleEditors = this . editorService . visibleControls ;
853-
854- // Close when empty: check if we should close the window based on the setting
855- // Overruled by: window has a workspace opened or this window is for extension development
856- // or setting is disabled. Also enabled when running with --wait from the command line.
857- if ( visibleEditors . length === 0 && this . contextService . getWorkbenchState ( ) === WorkbenchState . EMPTY && ! this . environmentService . isExtensionDevelopment ) {
858- const closeWhenEmpty = this . configurationService . getValue < boolean > ( Workbench . closeWhenEmptyConfigurationKey ) ;
859- if ( closeWhenEmpty || this . environmentService . args . wait ) {
860- this . closeEmptyWindowScheduler . schedule ( ) ;
861- }
862- }
863-
821+ private restoreHiddenEditor ( ) : void {
864822 if ( this . editorHidden ) {
865823 this . setEditorHidden ( false ) ;
866824 }
867825 }
868826
869- private onAllEditorsClosed ( ) : void {
870- const visibleEditors = this . editorService . visibleControls . length ;
871- if ( visibleEditors === 0 ) {
872- this . windowService . closeWindow ( ) ;
873- }
874- }
875-
876827 private onDidUpdateConfiguration ( skipLayout ?: boolean ) : void {
877828 const newSidebarPositionValue = this . configurationService . getValue < string > ( Workbench . sidebarPositionConfigurationKey ) ;
878829 const newSidebarPosition = ( newSidebarPositionValue === 'right' ) ? Position . RIGHT : Position . LEFT ;
0 commit comments