3
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
- import { IpcMainEvent , MessagePortMain } from 'electron' ;
7
6
import { Emitter , Event } from 'vs/base/common/event' ;
8
7
import { Disposable , toDisposable } from 'vs/base/common/lifecycle' ;
9
8
import { IProcessEnvironment , OperatingSystem , isWindows } from 'vs/base/common/platform' ;
10
9
import { ProxyChannel } from 'vs/base/parts/ipc/common/ipc' ;
11
- import { validatedIpcMain } from 'vs/base/parts/ipc/electron-main/ipcMain' ;
12
10
import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
13
11
import { ILogService , ILoggerService } from 'vs/platform/log/common/log' ;
14
12
import { RemoteLoggerChannelClient } from 'vs/platform/log/common/logIpc' ;
@@ -96,38 +94,14 @@ export class PtyHostService extends Disposable implements IPtyService {
96
94
this . _resolveVariablesRequestStore = this . _register ( new RequestStore ( undefined , this . _logService ) ) ;
97
95
this . _resolveVariablesRequestStore . onCreateRequest ( this . _onPtyHostRequestResolveVariables . fire , this . _onPtyHostRequestResolveVariables ) ;
98
96
99
- validatedIpcMain . on ( 'vscode:createPtyHostMessageChannel' , ( e , nonce ) => this . _onWindowConnection ( e , nonce ) ) ;
97
+ [ this . _connection , this . _proxy ] = this . _startPtyHost ( ) ;
100
98
101
- // TODO: Start on demand on first window connection (see SharedProcess.onWindowConnection
102
- // TODO: Make direct message port connection to each window when requested
103
-
104
- this . _startPtyHost ( ) . then ( value => {
105
- this . _connection = value [ 0 ] ;
106
- this . _proxy = value [ 1 ] ;
107
-
108
- this . _register ( this . _configurationService . onDidChangeConfiguration ( async e => {
109
- if ( e . affectsConfiguration ( TerminalSettingId . IgnoreProcessNames ) ) {
110
- await this . _refreshIgnoreProcessNames ( ) ;
111
- }
112
- } ) ) ;
113
- this . _refreshIgnoreProcessNames ( ) ;
114
- } ) ;
115
- }
116
-
117
- private _onWindowConnection ( e : IpcMainEvent , nonce : string ) {
118
- const port = this . _connection . connect ! ( ) as MessagePortMain ;
119
-
120
-
121
- // Check back if the requesting window meanwhile closed
122
- // Since shared process is delayed on startup there is
123
- // a chance that the window close before the shared process
124
- // was ready for a connection.
125
-
126
- if ( e . sender . isDestroyed ( ) ) {
127
- return port . close ( ) ;
128
- }
129
-
130
- e . sender . postMessage ( 'vscode:createPtyHostMessageChannelResult' , nonce , [ port ] ) ;
99
+ this . _register ( this . _configurationService . onDidChangeConfiguration ( async e => {
100
+ if ( e . affectsConfiguration ( TerminalSettingId . IgnoreProcessNames ) ) {
101
+ await this . _refreshIgnoreProcessNames ( ) ;
102
+ }
103
+ } ) ) ;
104
+ this . _refreshIgnoreProcessNames ( ) ;
131
105
}
132
106
133
107
private get _ignoreProcessNames ( ) : string [ ] {
@@ -152,8 +126,8 @@ export class PtyHostService extends Disposable implements IPtyService {
152
126
}
153
127
}
154
128
155
- private async _startPtyHost ( ) : Promise < [ IPtyHostConnection , IPtyService ] > {
156
- const connection = await this . _ptyHostStarter . start ( lastPtyId ) ;
129
+ private _startPtyHost ( ) : [ IPtyHostConnection , IPtyService ] {
130
+ const connection = this . _ptyHostStarter . start ( lastPtyId ) ;
157
131
const client = connection . client ;
158
132
159
133
this . _onPtyHostStart . fire ( ) ;
0 commit comments