@@ -36,9 +36,24 @@ let lastPtyId = 0;
36
36
export class PtyHostService extends Disposable implements IPtyService {
37
37
declare readonly _serviceBrand : undefined ;
38
38
39
- private _connection : IPtyHostConnection ;
39
+ private __connection ? : IPtyHostConnection ;
40
40
// ProxyChannel is not used here because events get lost when forwarding across multiple proxies
41
- private _proxy : IPtyService ;
41
+ private __proxy ?: IPtyService ;
42
+
43
+ private get _connection ( ) : IPtyHostConnection {
44
+ this . _ensurePtyHost ( ) ;
45
+ return this . __connection ! ;
46
+ }
47
+ private get _proxy ( ) : IPtyService {
48
+ this . _ensurePtyHost ( ) ;
49
+ return this . __proxy ! ;
50
+ }
51
+
52
+ private _ensurePtyHost ( ) {
53
+ if ( ! this . __connection ) {
54
+ [ this . __connection , this . __proxy ] = this . _startPtyHost ( ) ;
55
+ }
56
+ }
42
57
43
58
private readonly _shellEnv : Promise < typeof process . env > ;
44
59
private readonly _resolveVariablesRequestStore : RequestStore < string [ ] , { workspaceId : string ; originalText : string [ ] } > ;
@@ -93,14 +108,13 @@ export class PtyHostService extends Disposable implements IPtyService {
93
108
this . _resolveVariablesRequestStore = this . _register ( new RequestStore ( undefined , this . _logService ) ) ;
94
109
this . _resolveVariablesRequestStore . onCreateRequest ( this . _onPtyHostRequestResolveVariables . fire , this . _onPtyHostRequestResolveVariables ) ;
95
110
96
- [ this . _connection , this . _proxy ] = this . _startPtyHost ( ) ;
97
-
98
- this . _register ( this . _configurationService . onDidChangeConfiguration ( async e => {
99
- if ( e . affectsConfiguration ( TerminalSettingId . IgnoreProcessNames ) ) {
100
- await this . _refreshIgnoreProcessNames ( ) ;
101
- }
102
- } ) ) ;
103
- this . _refreshIgnoreProcessNames ( ) ;
111
+ // Force the pty host to start as the first window is starting if the starter has that
112
+ // capability
113
+ if ( this . _ptyHostStarter . onBeforeWindowConnection ) {
114
+ Event . once ( this . _ptyHostStarter . onBeforeWindowConnection ) ( ( ) => this . _ensurePtyHost ( ) ) ;
115
+ } else {
116
+ this . _ensurePtyHost ( ) ;
117
+ }
104
118
}
105
119
106
120
private get _ignoreProcessNames ( ) : string [ ] {
@@ -126,6 +140,7 @@ export class PtyHostService extends Disposable implements IPtyService {
126
140
}
127
141
128
142
private _startPtyHost ( ) : [ IPtyHostConnection , IPtyService ] {
143
+ this . _logService . info ( 'startPtyHost' , new Error ( ) . stack ) ;
129
144
const connection = this . _ptyHostStarter . start ( lastPtyId ) ;
130
145
const client = connection . client ;
131
146
@@ -166,6 +181,16 @@ export class PtyHostService extends Disposable implements IPtyService {
166
181
this . _register ( new RemoteLoggerChannelClient ( this . _loggerService , client . getChannel ( TerminalIpcChannels . Logger ) ) ) ;
167
182
} ) ;
168
183
184
+ this . __connection = connection ;
185
+ this . __proxy = proxy ;
186
+
187
+ this . _register ( this . _configurationService . onDidChangeConfiguration ( async e => {
188
+ if ( e . affectsConfiguration ( TerminalSettingId . IgnoreProcessNames ) ) {
189
+ await this . _refreshIgnoreProcessNames ( ) ;
190
+ }
191
+ } ) ) ;
192
+ this . _refreshIgnoreProcessNames ( ) ;
193
+
169
194
return [ connection , proxy ] ;
170
195
}
171
196
@@ -314,7 +339,7 @@ export class PtyHostService extends Disposable implements IPtyService {
314
339
async restartPtyHost ( ) : Promise < void > {
315
340
this . _disposePtyHost ( ) ;
316
341
this . _isResponsive = true ;
317
- [ this . _connection , this . _proxy ] = this . _startPtyHost ( ) ;
342
+ this . _startPtyHost ( ) ;
318
343
}
319
344
320
345
private _disposePtyHost ( ) : void {
0 commit comments