@@ -95,6 +95,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
9595 private _xtermReadyPromise : Promise < XTermTerminal > ;
9696 private _titleReadyPromise : Promise < string > ;
9797 private _titleReadyComplete : ( ( title : string ) => any ) | undefined ;
98+ private _areLinksReady : boolean = false ;
9899
99100 private _messageTitleDisposable : IDisposable | undefined ;
100101
@@ -127,7 +128,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
127128 // TODO: How does this work with detached processes?
128129 // TODO: Should this be an event as it can fire twice?
129130 public get processReady ( ) : Promise < void > { return this . _processManager . ptyProcessReady ; }
130- public get isXtermReady ( ) : boolean { return ! ! this . _xterm ; }
131+ public get areLinksReady ( ) : boolean { return this . _areLinksReady ; }
131132 public get xtermReady ( ) : Promise < void > { return this . _xtermReadyPromise . then ( ( ) => { } ) ; }
132133 public get exitCode ( ) : number | undefined { return this . _exitCode ; }
133134 public get title ( ) : string { return this . _title ; }
@@ -146,6 +147,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
146147 public get onFocused ( ) : Event < ITerminalInstance > { return this . _onFocused . event ; }
147148 private readonly _onProcessIdReady = new Emitter < ITerminalInstance > ( ) ;
148149 public get onProcessIdReady ( ) : Event < ITerminalInstance > { return this . _onProcessIdReady . event ; }
150+ private readonly _onLinksReady = new Emitter < ITerminalInstance > ( ) ;
151+ public get onLinksReady ( ) : Event < ITerminalInstance > { return this . _onLinksReady . event ; }
149152 private readonly _onTitleChanged = new Emitter < ITerminalInstance > ( ) ;
150153 public get onTitleChanged ( ) : Event < ITerminalInstance > { return this . _onTitleChanged . event ; }
151154 private readonly _onData = new Emitter < string > ( ) ;
@@ -203,14 +206,20 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
203206 this . _logService . trace ( `terminalInstance#ctor (id: ${ this . id } )` , this . _shellLaunchConfig ) ;
204207
205208 this . _initDimensions ( ) ;
206- this . _createProcess ( ) ;
209+ this . _createProcessManager ( ) ;
207210
208211 this . _xtermReadyPromise = this . _createXterm ( ) ;
209212 this . _xtermReadyPromise . then ( ( ) => {
210213 // Only attach xterm.js to the DOM if the terminal panel has been opened before.
211214 if ( _container ) {
212215 this . _attachToElement ( _container ) ;
213216 }
217+
218+ this . _processManager . createProcess ( this . _shellLaunchConfig , this . _cols , this . _rows , this . _accessibilityService . isScreenReaderOptimized ( ) ) . then ( error => {
219+ if ( error ) {
220+ this . _onProcessExit ( error ) ;
221+ }
222+ } ) ;
214223 } ) ;
215224
216225 this . addDisposable ( this . _configurationService . onDidChangeConfiguration ( e => {
@@ -418,6 +427,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
418427 e . terminal = this ;
419428 this . _onBeforeHandleLink . fire ( e ) ;
420429 } ) ;
430+ this . _areLinksReady = true ;
431+ this . _onLinksReady . fire ( this ) ;
421432 } ) ;
422433
423434 this . _commandTrackerAddon = new CommandTrackerAddon ( ) ;
@@ -870,9 +881,12 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
870881 this . _terminalHasTextContextKey . set ( isActive && this . hasSelection ( ) ) ;
871882 }
872883
873- protected _createProcess ( ) : void {
884+ protected _createProcessManager ( ) : void {
874885 this . _processManager = this . _instantiationService . createInstance ( TerminalProcessManager , this . _id , this . _configHelper ) ;
875- this . _processManager . onProcessReady ( ( ) => this . _onProcessIdReady . fire ( this ) ) ;
886+ this . _processManager . onProcessReady ( ( ) => {
887+ console . log ( '_processManager.onProcessReady' ) ;
888+ this . _onProcessIdReady . fire ( this ) ;
889+ } ) ;
876890 this . _processManager . onProcessExit ( exitCode => this . _onProcessExit ( exitCode ) ) ;
877891 this . _processManager . onProcessData ( data => this . _onData . fire ( data ) ) ;
878892 this . _processManager . onProcessOverrideDimensions ( e => this . setDimensions ( e ) ) ;
@@ -916,14 +930,6 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
916930 } ) ;
917931 } ) ;
918932 }
919-
920- // Create the process asynchronously to allow the terminal's container to be created so
921- // dimensions are accurate
922- this . _processManager . createProcess ( this . _shellLaunchConfig , this . _cols , this . _rows , this . _accessibilityService . isScreenReaderOptimized ( ) ) . then ( error => {
923- if ( error ) {
924- this . _onProcessExit ( error ) ;
925- }
926- } ) ;
927933 }
928934
929935 private getShellType ( executable : string ) : TerminalShellType {
@@ -1110,7 +1116,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
11101116 // Launch the process unless this is only a renderer.
11111117 // In the renderer only cases, we still need to set the title correctly.
11121118 const oldTitle = this . _title ;
1113- this . _createProcess ( ) ;
1119+ this . _createProcessManager ( ) ;
11141120
11151121 if ( oldTitle !== this . _title ) {
11161122 this . setTitle ( this . _title , TitleEventSource . Process ) ;
@@ -1497,7 +1503,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
14971503
14981504 public registerLinkProvider ( provider : ITerminalExternalLinkProvider ) : IDisposable {
14991505 if ( ! this . _linkManager ) {
1500- throw new Error ( 'TerminalInstance.registerLinkProvider before xterm was created ' ) ;
1506+ throw new Error ( 'TerminalInstance.registerLinkProvider before link manager was ready ' ) ;
15011507 }
15021508 return this . _linkManager . registerExternalLinkProvider ( this , provider ) ;
15031509 }
0 commit comments