提交 811b7441 编写于 作者: D Daniel Imms

Clean up process creation and check connected before sending

上级 414e19a5
......@@ -6,6 +6,7 @@
import * as vscode from 'vscode';
import * as cp from 'child_process';
import * as os from 'os';
import * as platform from 'vs/base/common/platform';
import * as terminalEnvironment from 'vs/workbench/parts/terminal/node/terminalEnvironment';
import Uri from 'vs/base/common/uri';
......@@ -202,9 +203,12 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape {
}
this._logService.info('$createProcess', id, shellLaunchConfig, cols, rows);
// TODO: Base the cwd on the last active workspace root
// const lastActiveWorkspaceRootUri = this._historyService.getLastActiveWorkspaceRoot('file');
// this.initialCwd = terminalEnvironment.getCwd(shellLaunchConfig, lastActiveWorkspaceRootUri, this._configHelper);
const initialCwd = os.homedir();
// TODO: Pull in and resolve config settings
// // Resolve env vars from config and shell
// const lastActiveWorkspaceRoot = this._workspaceContextService.getWorkspaceFolder(lastActiveWorkspaceRootUri);
// const platformKey = platform.isWindows ? 'windows' : (platform.isMacintosh ? 'osx' : 'linux');
......@@ -212,34 +216,19 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape {
// const envFromShell = terminalEnvironment.resolveConfigurationVariables(this._configurationResolverService, { ...shellLaunchConfig.env }, lastActiveWorkspaceRoot);
// shellLaunchConfig.env = envFromShell;
// // Merge process env with the env from config
// const parentEnv = { ...process.env };
// Merge process env with the env from config
const parentEnv = { ...process.env };
// terminalEnvironment.mergeEnvironments(parentEnv, envFromConfig);
// // Continue env initialization, merging in the env from the launch
// // config and adding keys that are needed to create the process
// const env = terminalEnvironment.createTerminalEnv(parentEnv, shellLaunchConfig, this.initialCwd, locale, cols, rows);
// const cwd = Uri.parse(paths.dirname(require.toUrl('../node/terminalProcess'))).fsPath;
// const options = { env, cwd };
// TODO: Launch process
// TODO: Associate the process with the terminal object/id
// TODO: terminal has incorrect name/options, fix up
const parentEnv = { ...process.env };
const env = terminalEnvironment.createTerminalEnv(parentEnv, shellLaunchConfig, '/home/daniel', locale, cols, rows);
// TODO: Use Uri?
// Continue env initialization, merging in the env from the launch
// config and adding keys that are needed to create the process
const env = terminalEnvironment.createTerminalEnv(parentEnv, shellLaunchConfig, initialCwd, locale, cols, rows);
let cwd = Uri.parse(require.toUrl('../../parts/terminal/node')).fsPath;
const options = { env, cwd, execArgv: [] };
let bootstrapUri = Uri.parse(require.toUrl('bootstrap')).fsPath;
// Fork the process and listen for messages
this._logService.debug(`Terminal process launching on ext host`, options);
this._terminalProcesses[id] = cp.fork(bootstrapUri, ['--type=terminal'], options);
this._terminalProcesses[id] = cp.fork(Uri.parse(require.toUrl('bootstrap')).fsPath, ['--type=terminal'], options);
this._terminalProcesses[id].on('message', (message: IMessageFromTerminalProcess) => {
switch (message.type) {
case 'pid': this._proxy.$sendProcessPid(id, <number>message.content); break;
......@@ -250,17 +239,22 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape {
}
public $acceptTerminalProcessInput(id: number, data: string): void {
if (this._terminalProcesses[id].connected) {
this._terminalProcesses[id].send({ event: 'input', data });
}
}
public $acceptTerminalProcessResize(id: number, cols: number, rows: number): void {
console.log('resize' + cols + ',' + rows);
if (this._terminalProcesses[id].connected) {
this._terminalProcesses[id].send({ event: 'resize', cols, rows });
}
}
public $acceptTerminalProcessShutdown(id: number): void {
if (this._terminalProcesses[id].connected) {
this._terminalProcesses[id].send({ event: 'shutdown' });
}
}
private _getTerminalById(id: number): ExtHostTerminal {
let index = this._getTerminalIndexById(id);
......@@ -283,7 +277,6 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape {
}
class ApiRequest {
private _callback: (...args: any[]) => void;
private _args: any[];
......
......@@ -9,7 +9,7 @@ import { ITerminalService, ITerminalProcessExtHostProxy, IShellLaunchConfig } fr
import { IDisposable } from '../../../../base/common/lifecycle';
export class TerminalProcessExtHostProxy extends EventEmitter implements ITerminalChildProcess, ITerminalProcessExtHostProxy {
// TODO: Set this properly
// For ext host processes connected checks happen on the ext host
public connected: boolean = true;
constructor(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册