@@ -32,8 +32,8 @@ import { IStorageMainService } from 'vs/platform/storage/electron-main/storageMa
32
32
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry' ;
33
33
import { ThemeIcon } from 'vs/platform/theme/common/themeService' ;
34
34
import { IThemeMainService } from 'vs/platform/theme/electron-main/themeMainService' ;
35
- import { getMenuBarVisibility , getTitleBarStyle , INativeWindowConfiguration , IWindowSettings , MenuBarVisibility , WindowMinimumSize , zoomLevelToZoomFactor } from 'vs/platform/windows/common/windows' ;
36
- import { defaultWindowState , ICodeWindow , ILoadEvent , IWindowState , LoadReason , WindowError , WindowMode } from 'vs/platform/windows/electron-main/windows' ;
35
+ import { getMenuBarVisibility , getTitleBarStyle , IFolderToOpen , INativeWindowConfiguration , IWindowSettings , IWorkspaceToOpen , MenuBarVisibility , WindowMinimumSize , zoomLevelToZoomFactor } from 'vs/platform/windows/common/windows' ;
36
+ import { defaultWindowState , ICodeWindow , ILoadEvent , IWindowsMainService , IWindowState , LoadReason , OpenContext , WindowError , WindowMode } from 'vs/platform/windows/electron-main/windows' ;
37
37
import { ISingleFolderWorkspaceIdentifier , isSingleFolderWorkspaceIdentifier , isWorkspaceIdentifier , IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces' ;
38
38
import { IWorkspacesManagementMainService } from 'vs/platform/workspaces/electron-main/workspacesManagementMainService' ;
39
39
@@ -158,7 +158,8 @@ export class CodeWindow extends Disposable implements ICodeWindow {
158
158
@IDialogMainService private readonly dialogMainService : IDialogMainService ,
159
159
@ILifecycleMainService private readonly lifecycleMainService : ILifecycleMainService ,
160
160
@IProductService private readonly productService : IProductService ,
161
- @IProtocolMainService private readonly protocolMainService : IProtocolMainService
161
+ @IProtocolMainService private readonly protocolMainService : IProtocolMainService ,
162
+ @IWindowsMainService private readonly windowsMainService : IWindowsMainService
162
163
) {
163
164
super ( ) ;
164
165
@@ -617,15 +618,10 @@ export class CodeWindow extends Disposable implements ICodeWindow {
617
618
cancelId : 1
618
619
} , this . _win ) ;
619
620
620
- if ( ! this . _win ) {
621
- return ; // Return early if the window has been going down already
622
- }
623
-
624
- if ( result . response === 0 ) {
625
- this . _win . webContents . forcefullyCrashRenderer ( ) ; // Calling reload() immediately after calling this method will force the reload to occur in a new process
626
- this . reload ( ) ;
627
- } else if ( result . response === 2 ) {
628
- this . destroyWindow ( ) ;
621
+ // Handle choice
622
+ if ( result . response !== 1 /* keep waiting */ ) {
623
+ const reopen = result . response === 0 ;
624
+ this . destroyWindow ( reopen ) ;
629
625
}
630
626
}
631
627
@@ -638,6 +634,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
638
634
message = localize ( 'appCrashedDetails' , "The window has crashed (reason: '{0}', code: '{1}')" , details . reason , details . exitCode ?? '<unknown>' ) ;
639
635
}
640
636
637
+ // Show Dialog
641
638
const result = await this . dialogMainService . showMessageBox ( {
642
639
title : this . productService . nameLong ,
643
640
type : 'warning' ,
@@ -651,23 +648,49 @@ export class CodeWindow extends Disposable implements ICodeWindow {
651
648
defaultId : 0
652
649
} , this . _win ) ;
653
650
654
- if ( ! this . _win ) {
655
- return ; // Return early if the window has been going down already
656
- }
657
-
658
- if ( result . response === 0 ) {
659
- this . reload ( ) ;
660
- } else if ( result . response === 1 ) {
661
- this . destroyWindow ( ) ;
662
- }
651
+ // Handle choice
652
+ const reopen = result . response === 0 ;
653
+ this . destroyWindow ( reopen ) ;
663
654
}
664
655
break ;
665
656
}
666
657
}
667
658
668
- private destroyWindow ( ) : void {
669
- this . _onDidDestroy . fire ( ) ; // 'close' event will not be fired on destroy(), so signal crash via explicit event
670
- this . _win . destroy ( ) ; // make sure to destroy the window as it has crashed
659
+ private destroyWindow ( reopen : boolean ) : void {
660
+
661
+ // 'close' event will not be fired on destroy(), so signal crash via explicit event
662
+ this . _onDidDestroy . fire ( ) ;
663
+
664
+ // make sure to destroy the window as it has crashed
665
+ this . _win ?. destroy ( ) ;
666
+
667
+ // ask the windows service to open a new fresh window if specified
668
+ if ( reopen && this . config ) {
669
+
670
+ // We have to reconstruct a openable from the current workspace
671
+ let workspace : IWorkspaceToOpen | IFolderToOpen | undefined = undefined ;
672
+ let forceEmpty = undefined ;
673
+ if ( isSingleFolderWorkspaceIdentifier ( this . openedWorkspace ) ) {
674
+ workspace = { folderUri : this . openedWorkspace . uri } ;
675
+ } else if ( isWorkspaceIdentifier ( this . openedWorkspace ) ) {
676
+ workspace = { workspaceUri : this . openedWorkspace . configPath } ;
677
+ } else {
678
+ forceEmpty = true ;
679
+ }
680
+
681
+ // Delegate to windows service
682
+ const [ window ] = this . windowsMainService . open ( {
683
+ context : OpenContext . API ,
684
+ userEnv : this . config . userEnv ,
685
+ cli : {
686
+ ...this . environmentMainService . args ,
687
+ _ : [ ] // we pass in the workspace to open explicitly via `urisToOpen`
688
+ } ,
689
+ urisToOpen : workspace ? [ workspace ] : undefined ,
690
+ forceEmpty
691
+ } ) ;
692
+ window . focus ( ) ;
693
+ }
671
694
}
672
695
673
696
private onDidDeleteUntitledWorkspace ( workspace : IWorkspaceIdentifier ) : void {
0 commit comments