@@ -109,7 +109,6 @@ import { IExtensionsScannerService } from 'vs/platform/extensionManagement/commo
109109import { ExtensionsScannerService } from 'vs/platform/extensionManagement/node/extensionsScannerService' ;
110110import { UserDataTransientProfilesHandler } from 'vs/platform/userDataProfile/electron-main/userDataTransientProfilesHandler' ;
111111import { Promises , RunOnceScheduler , runWhenIdle } from 'vs/base/common/async' ;
112- import { IUserDataProfile } from 'vs/platform/userDataProfile/common/userDataProfile' ;
113112
114113/**
115114 * The main VS Code application. There will only ever be one instance,
@@ -326,12 +325,12 @@ export class CodeApplication extends Disposable {
326325 } ) ;
327326
328327 // macOS dock activate
329- app . on ( 'activate' , ( event , hasVisibleWindows ) => {
328+ app . on ( 'activate' , async ( event , hasVisibleWindows ) => {
330329 this . logService . trace ( 'app#activate' ) ;
331330
332331 // Mac only event: open new window when we get activated
333332 if ( ! hasVisibleWindows ) {
334- this . windowsMainService ?. openEmptyWindow ( { context : OpenContext . DOCK } ) ;
333+ await this . windowsMainService ?. openEmptyWindow ( { context : OpenContext . DOCK } ) ;
335334 }
336335 } ) ;
337336
@@ -372,8 +371,8 @@ export class CodeApplication extends Disposable {
372371 }
373372
374373 // Handle paths delayed in case more are coming!
375- runningTimeout = setTimeout ( ( ) => {
376- this . windowsMainService ?. open ( {
374+ runningTimeout = setTimeout ( async ( ) => {
375+ await this . windowsMainService ?. open ( {
377376 context : OpenContext . DOCK /* can also be opening from finder while app is running */ ,
378377 cli : this . environmentMainService . args ,
379378 urisToOpen : macOpenFileURIs ,
@@ -386,8 +385,8 @@ export class CodeApplication extends Disposable {
386385 } , 100 ) ;
387386 } ) ;
388387
389- app . on ( 'new-window-for-tab' , ( ) => {
390- this . windowsMainService ?. openEmptyWindow ( { context : OpenContext . DESKTOP } ) ; //macOS native tab "+" button
388+ app . on ( 'new-window-for-tab' , async ( ) => {
389+ await this . windowsMainService ?. openEmptyWindow ( { context : OpenContext . DESKTOP } ) ; //macOS native tab "+" button
391390 } ) ;
392391
393392 //#region Bootstrap IPC Handlers
@@ -537,15 +536,11 @@ export class CodeApplication extends Disposable {
537536 // Setup Handlers
538537 this . setUpHandlers ( appInstantiationService ) ;
539538
540- // Ensure profile exists when passed in from CLI
541- const profilePromise = this . userDataProfilesMainService . checkAndCreateProfileFromCli ( this . environmentMainService . args ) ;
542- const profile = profilePromise ? await profilePromise : undefined ;
543-
544539 // Init Channels
545540 appInstantiationService . invokeFunction ( accessor => this . initChannels ( accessor , mainProcessElectronServer , sharedProcessClient ) ) ;
546541
547542 // Open Windows
548- appInstantiationService . invokeFunction ( accessor => this . openFirstWindow ( accessor , profile , mainProcessElectronServer ) ) ;
543+ await appInstantiationService . invokeFunction ( accessor => this . openFirstWindow ( accessor , mainProcessElectronServer ) ) ;
549544
550545 // Post Open Windows Tasks
551546 appInstantiationService . invokeFunction ( accessor => this . afterWindowOpen ( accessor , sharedProcess ) ) ;
@@ -834,7 +829,7 @@ export class CodeApplication extends Disposable {
834829 mainProcessElectronServer . registerChannel ( ipcExtensionHostStarterChannelName , extensionHostStarterChannel ) ;
835830 }
836831
837- private openFirstWindow ( accessor : ServicesAccessor , profile : IUserDataProfile | undefined , mainProcessElectronServer : ElectronIPCServer ) : ICodeWindow [ ] {
832+ private async openFirstWindow ( accessor : ServicesAccessor , mainProcessElectronServer : ElectronIPCServer ) : Promise < ICodeWindow [ ] > {
838833 const windowsMainService = this . windowsMainService = accessor . get ( IWindowsMainService ) ;
839834 const urlService = accessor . get ( IURLService ) ;
840835 const nativeHostMainService = accessor . get ( INativeHostMainService ) ;
@@ -922,7 +917,7 @@ export class CodeApplication extends Disposable {
922917 const windowOpenableFromProtocolLink = app . getWindowOpenableFromProtocolLink ( uri ) ;
923918 logService . trace ( 'app#handleURL: windowOpenableFromProtocolLink = ' , windowOpenableFromProtocolLink ) ;
924919 if ( windowOpenableFromProtocolLink ) {
925- const [ window ] = windowsMainService . open ( {
920+ const [ window ] = await windowsMainService . open ( {
926921 context : OpenContext . API ,
927922 cli : { ...environmentService . args } ,
928923 urisToOpen : [ windowOpenableFromProtocolLink ] ,
@@ -937,7 +932,7 @@ export class CodeApplication extends Disposable {
937932 }
938933
939934 if ( shouldOpenInNewWindow ) {
940- const [ window ] = windowsMainService . open ( {
935+ const [ window ] = await windowsMainService . open ( {
941936 context : OpenContext . API ,
942937 cli : { ...environmentService . args } ,
943938 forceNewWindow : true ,
@@ -994,6 +989,9 @@ export class CodeApplication extends Disposable {
994989 } ) ;
995990 }
996991
992+ // Ensure profile exists when passed in from CLI
993+ const profile = await this . userDataProfilesMainService . checkAndCreateProfileFromCli ( this . environmentMainService . args ) ;
994+
997995 // Start without file/folder arguments
998996 if ( ! hasCliArgs && ! hasFolderURIs && ! hasFileURIs ) {
999997
0 commit comments