@@ -76,7 +76,8 @@ interface IOpenBrowserWindowOptions {
76
76
readonly windowToUse ?: ICodeWindow ;
77
77
78
78
readonly emptyWindowBackupInfo ?: IEmptyWindowBackupInfo ;
79
- readonly profile ?: IUserDataProfile ;
79
+ readonly forceProfile ?: string ;
80
+ readonly forceTempProfile ?: boolean ;
80
81
}
81
82
82
83
interface IPathResolveOptions {
@@ -521,15 +522,16 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
521
522
522
523
// Finally, if no window or folder is found, just open the files in an empty window
523
524
else {
524
- addUsedWindow ( this . openInBrowserWindow ( {
525
+ addUsedWindow ( await this . openInBrowserWindow ( {
525
526
userEnv : openConfig . userEnv ,
526
527
cli : openConfig . cli ,
527
528
initialStartup : openConfig . initialStartup ,
528
529
filesToOpen,
529
530
forceNewWindow : true ,
530
531
remoteAuthority : filesToOpen . remoteAuthority ,
531
532
forceNewTabbedWindow : openConfig . forceNewTabbedWindow ,
532
- profile : openConfig . profile
533
+ forceProfile : openConfig . forceProfile ,
534
+ forceTempProfile : openConfig . forceTempProfile
533
535
} ) , true ) ;
534
536
}
535
537
}
@@ -560,7 +562,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
560
562
const filesToOpenInWindow = isEqualAuthority ( filesToOpen ?. remoteAuthority , remoteAuthority ) ? filesToOpen : undefined ;
561
563
562
564
// Do open folder
563
- addUsedWindow ( this . doOpenFolderOrWorkspace ( openConfig , workspaceToOpen , openFolderInNewWindow , filesToOpenInWindow ) , ! ! filesToOpenInWindow ) ;
565
+ addUsedWindow ( await this . doOpenFolderOrWorkspace ( openConfig , workspaceToOpen , openFolderInNewWindow , filesToOpenInWindow ) , ! ! filesToOpenInWindow ) ;
564
566
565
567
openFolderInNewWindow = true ; // any other folders to open must open in new window then
566
568
}
@@ -592,7 +594,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
592
594
const filesToOpenInWindow = isEqualAuthority ( filesToOpen ?. remoteAuthority , remoteAuthority ) ? filesToOpen : undefined ;
593
595
594
596
// Do open folder
595
- addUsedWindow ( this . doOpenFolderOrWorkspace ( openConfig , folderToOpen , openFolderInNewWindow , filesToOpenInWindow ) , ! ! filesToOpenInWindow ) ;
597
+ addUsedWindow ( await this . doOpenFolderOrWorkspace ( openConfig , folderToOpen , openFolderInNewWindow , filesToOpenInWindow ) , ! ! filesToOpenInWindow ) ;
596
598
597
599
openFolderInNewWindow = true ; // any other folders to open must open in new window then
598
600
}
@@ -605,7 +607,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
605
607
const remoteAuthority = emptyWindowBackupInfo . remoteAuthority ;
606
608
const filesToOpenInWindow = isEqualAuthority ( filesToOpen ?. remoteAuthority , remoteAuthority ) ? filesToOpen : undefined ;
607
609
608
- addUsedWindow ( this . doOpenEmpty ( openConfig , true , remoteAuthority , filesToOpenInWindow , emptyWindowBackupInfo ) , ! ! filesToOpenInWindow ) ;
610
+ addUsedWindow ( await this . doOpenEmpty ( openConfig , true , remoteAuthority , filesToOpenInWindow , emptyWindowBackupInfo ) , ! ! filesToOpenInWindow ) ;
609
611
610
612
openFolderInNewWindow = true ; // any other folders to open must open in new window then
611
613
}
@@ -620,7 +622,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
620
622
const remoteAuthority = filesToOpen ? filesToOpen . remoteAuthority : openConfig . remoteAuthority ;
621
623
622
624
for ( let i = 0 ; i < emptyToOpen ; i ++ ) {
623
- addUsedWindow ( this . doOpenEmpty ( openConfig , openFolderInNewWindow , remoteAuthority , filesToOpen ) , ! ! filesToOpen ) ;
625
+ addUsedWindow ( await this . doOpenEmpty ( openConfig , openFolderInNewWindow , remoteAuthority , filesToOpen ) , ! ! filesToOpen ) ;
624
626
625
627
// any other window to open must open in new window then
626
628
openFolderInNewWindow = true ;
@@ -658,7 +660,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
658
660
return window ;
659
661
}
660
662
661
- private doOpenEmpty ( openConfig : IOpenConfiguration , forceNewWindow : boolean , remoteAuthority : string | undefined , filesToOpen : IFilesToOpen | undefined , emptyWindowBackupInfo ?: IEmptyWindowBackupInfo ) : ICodeWindow {
663
+ private doOpenEmpty ( openConfig : IOpenConfiguration , forceNewWindow : boolean , remoteAuthority : string | undefined , filesToOpen : IFilesToOpen | undefined , emptyWindowBackupInfo ?: IEmptyWindowBackupInfo ) : Promise < ICodeWindow > {
662
664
this . logService . trace ( 'windowsManager#doOpenEmpty' , { restore : ! ! emptyWindowBackupInfo , remoteAuthority, filesToOpen, forceNewWindow } ) ;
663
665
664
666
let windowToUse : ICodeWindow | undefined ;
@@ -676,11 +678,12 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
676
678
filesToOpen,
677
679
windowToUse,
678
680
emptyWindowBackupInfo,
679
- profile : openConfig . profile
681
+ forceProfile : openConfig . forceProfile ,
682
+ forceTempProfile : openConfig . forceTempProfile
680
683
} ) ;
681
684
}
682
685
683
- private doOpenFolderOrWorkspace ( openConfig : IOpenConfiguration , folderOrWorkspace : IWorkspacePathToOpen | ISingleFolderWorkspacePathToOpen , forceNewWindow : boolean , filesToOpen : IFilesToOpen | undefined , windowToUse ?: ICodeWindow ) : ICodeWindow {
686
+ private doOpenFolderOrWorkspace ( openConfig : IOpenConfiguration , folderOrWorkspace : IWorkspacePathToOpen | ISingleFolderWorkspacePathToOpen , forceNewWindow : boolean , filesToOpen : IFilesToOpen | undefined , windowToUse ?: ICodeWindow ) : Promise < ICodeWindow > {
684
687
this . logService . trace ( 'windowsManager#doOpenFolderOrWorkspace' , { folderOrWorkspace, filesToOpen } ) ;
685
688
686
689
if ( ! forceNewWindow && ! windowToUse && typeof openConfig . contextWindowId === 'number' ) {
@@ -697,7 +700,8 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
697
700
forceNewTabbedWindow : openConfig . forceNewTabbedWindow ,
698
701
filesToOpen,
699
702
windowToUse,
700
- profile : openConfig . profile
703
+ forceProfile : openConfig . forceProfile ,
704
+ forceTempProfile : openConfig . forceTempProfile
701
705
} ) ;
702
706
}
703
707
@@ -1303,13 +1307,14 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
1303
1307
noRecentEntry : true ,
1304
1308
waitMarkerFileURI : openConfig . waitMarkerFileURI ,
1305
1309
remoteAuthority,
1306
- profile : openConfig . profile
1310
+ forceProfile : openConfig . forceProfile ,
1311
+ forceTempProfile : openConfig . forceTempProfile
1307
1312
} ;
1308
1313
1309
1314
return this . open ( openArgs ) ;
1310
1315
}
1311
1316
1312
- private openInBrowserWindow ( options : IOpenBrowserWindowOptions ) : ICodeWindow {
1317
+ private async openInBrowserWindow ( options : IOpenBrowserWindowOptions ) : Promise < ICodeWindow > {
1313
1318
const windowConfig = this . configurationService . getValue < IWindowSettings | undefined > ( 'window' ) ;
1314
1319
1315
1320
// Build up the window configuration from provided options, config and environment
@@ -1337,7 +1342,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
1337
1342
1338
1343
profiles : {
1339
1344
all : this . userDataProfilesMainService . profiles ,
1340
- profile : this . resolveProfileForBrowserWindow ( options )
1345
+ profile : await this . resolveProfileForBrowserWindow ( options )
1341
1346
} ,
1342
1347
1343
1348
homeDir : this . environmentMainService . userHome . fsPath ,
@@ -1497,19 +1502,20 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
1497
1502
window . load ( configuration ) ;
1498
1503
}
1499
1504
1500
- private resolveProfileForBrowserWindow ( options : IOpenBrowserWindowOptions ) : IUserDataProfile {
1501
-
1502
- // Use the provided profile if any
1503
- let profile = options . profile ;
1505
+ private async resolveProfileForBrowserWindow ( options : IOpenBrowserWindowOptions ) : Promise < IUserDataProfile > {
1506
+ let profile : IUserDataProfile | undefined ;
1507
+ if ( this . userDataProfilesMainService . isEnabled ( ) ) {
1508
+ if ( options . forceProfile ) {
1509
+ profile = this . userDataProfilesMainService . profiles . find ( p => p . name === options . forceProfile ) ?? await this . userDataProfilesMainService . createNamedProfile ( options . forceProfile ) ;
1510
+ } else if ( options . forceTempProfile ) {
1511
+ profile = await this . userDataProfilesMainService . createTransientProfile ( ) ;
1512
+ }
1513
+ }
1504
1514
if ( profile ) {
1505
1515
this . userDataProfilesMainService . setProfileForWorkspaceSync ( options . workspace ?? 'empty-window' , profile ) ;
1506
- }
1507
-
1508
- // Otherwise use associated profile
1509
- if ( ! profile ) {
1516
+ } else {
1510
1517
profile = this . userDataProfilesMainService . getOrSetProfileForWorkspace ( options . workspace ?? 'empty-window' , ( options . windowToUse ?? this . getLastActiveWindow ( ) ) ?. profile ?? this . userDataProfilesMainService . defaultProfile ) ;
1511
1518
}
1512
-
1513
1519
return profile ;
1514
1520
}
1515
1521
0 commit comments