@@ -14,12 +14,7 @@ import { ILogService } from 'vs/platform/log/common/log';
1414import { EXT_HOST_CREATION_DELAY } from 'vs/workbench/contrib/terminal/common/terminal' ;
1515import { TerminalProcess } from 'vs/workbench/contrib/terminal/node/terminalProcess' ;
1616import { timeout } from 'vs/base/common/async' ;
17- import { generateRandomPipeName } from 'vs/base/parts/ipc/node/ipc.net' ;
18- import * as http from 'http' ;
19- import * as fs from 'fs' ;
20- import { ExtHostCommands } from 'vs/workbench/api/node/extHostCommands' ;
2117import { sanitizeProcessEnvironment } from 'vs/base/node/processes' ;
22- import { IURIToOpen , URIType } from 'vs/platform/windows/common/windows' ;
2318
2419const RENDERER_NO_PROCESS_ID = - 1 ;
2520
@@ -270,7 +265,6 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape {
270265 private _terminalProcesses : { [ id : number ] : TerminalProcess } = { } ;
271266 private _terminalRenderers : ExtHostTerminalRenderer [ ] = [ ] ;
272267 private _getTerminalPromises : { [ id : number ] : Promise < ExtHostTerminal > } = { } ;
273- private _cliServer : CLIServer | undefined ;
274268
275269 public get activeTerminal ( ) : ExtHostTerminal { return this . _activeTerminal ; }
276270 public get terminals ( ) : ExtHostTerminal [ ] { return this . _terminals ; }
@@ -288,7 +282,6 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape {
288282 mainContext : IMainContext ,
289283 private _extHostConfiguration : ExtHostConfiguration ,
290284 private _logService : ILogService ,
291- private _commands : ExtHostCommands
292285 ) {
293286 this . _proxy = mainContext . getProxy ( MainContext . MainThreadTerminalService ) ;
294287 }
@@ -453,17 +446,12 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape {
453446
454447 // Sanitize the environment, removing any undesirable VS Code and Electron environment
455448 // variables
456- sanitizeProcessEnvironment ( env ) ;
449+ sanitizeProcessEnvironment ( env , 'VSCODE_IPC_HOOK_CLI' ) ;
457450
458451 // Continue env initialization, merging in the env from the launch
459452 // config and adding keys that are needed to create the process
460453 terminalEnvironment . addTerminalEnvironmentKeys ( env , platform . locale , terminalConfig . get ( 'setLocaleVariables' ) ) ;
461454
462- if ( ! this . _cliServer ) {
463- this . _cliServer = new CLIServer ( this . _commands ) ;
464- }
465- env [ 'VSCODE_IPC_HOOK_CLI' ] = this . _cliServer . ipcHandlePath ;
466-
467455 // Fork the process and listen for messages
468456 this . _logService . debug ( `Terminal process launching on ext host` , shellLaunchConfig , initialCwd , cols , rows , env ) ;
469457 const p = new TerminalProcess ( shellLaunchConfig , initialCwd , cols , rows , env , terminalConfig . get ( 'windowsEnableConpty' ) ) ;
@@ -512,11 +500,6 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape {
512500 // Send exit event to main side
513501 this . _proxy . $sendProcessExit ( id , exitCode ) ;
514502
515- if ( this . _cliServer && ! Object . keys ( this . _terminalProcesses ) . length ) {
516- this . _cliServer . dispose ( ) ;
517- this . _cliServer = undefined ;
518- }
519-
520503 }
521504
522505 private _getTerminalByIdEventually ( id : number , retries : number = 5 ) : Promise < ExtHostTerminal > {
@@ -588,74 +571,3 @@ class ApiRequest {
588571 this . _callback . apply ( proxy , [ id ] . concat ( this . _args ) ) ;
589572 }
590573}
591-
592-
593- class CLIServer {
594-
595- private _server : http . Server ;
596- private _ipcHandlePath : string | undefined ;
597-
598- constructor ( private _commands : ExtHostCommands ) {
599- this . _server = http . createServer ( ( req , res ) => this . onRequest ( req , res ) ) ;
600- this . setup ( ) . catch ( err => {
601- console . error ( err ) ;
602- return '' ;
603- } ) ;
604- }
605-
606- public get ipcHandlePath ( ) {
607- return this . _ipcHandlePath ;
608- }
609-
610- private async setup ( ) : Promise < string > {
611- this . _ipcHandlePath = generateRandomPipeName ( ) ;
612-
613- try {
614- this . _server . listen ( this . ipcHandlePath ) ;
615- this . _server . on ( 'error' , err => console . error ( err ) ) ;
616- } catch ( err ) {
617- console . error ( 'Could not start open from terminal server.' ) ;
618- }
619-
620- return this . ipcHandlePath ;
621- }
622- private collectURIToOpen ( strs : string [ ] , typeHint : URIType , result : IURIToOpen [ ] ) : void {
623- if ( Array . isArray ( strs ) ) {
624- for ( const s of strs ) {
625- try {
626- result . push ( { uri : URI . parse ( s ) , typeHint } ) ;
627- } catch ( e ) {
628- // ignore
629- }
630- }
631- }
632- }
633-
634- private onRequest ( req : http . IncomingMessage , res : http . ServerResponse ) : void {
635- const chunks : string [ ] = [ ] ;
636- req . setEncoding ( 'utf8' ) ;
637- req . on ( 'data' , ( d : string ) => chunks . push ( d ) ) ;
638- req . on ( 'end' , ( ) => {
639- let { fileURIs, folderURIs, forceNewWindow, diffMode, addMode, forceReuseWindow } = JSON . parse ( chunks . join ( '' ) ) ;
640- if ( folderURIs && folderURIs . length || fileURIs && fileURIs . length ) {
641- if ( folderURIs && folderURIs . length && ! forceReuseWindow ) {
642- forceNewWindow = true ;
643- }
644- const urisToOpen : IURIToOpen [ ] = [ ] ;
645- this . collectURIToOpen ( folderURIs , 'folder' , urisToOpen ) ;
646- this . collectURIToOpen ( fileURIs , 'file' , urisToOpen ) ;
647- this . _commands . executeCommand ( '_files.windowOpen' , { urisToOpen, forceNewWindow, diffMode, addMode, forceReuseWindow } ) ;
648- }
649- res . writeHead ( 200 ) ;
650- res . end ( ) ;
651- } ) ;
652- }
653-
654- dispose ( ) : void {
655- this . _server . close ( ) ;
656-
657- if ( this . _ipcHandlePath && process . platform !== 'win32' && fs . existsSync ( this . _ipcHandlePath ) ) {
658- fs . unlinkSync ( this . _ipcHandlePath ) ;
659- }
660- }
661- }
0 commit comments