From 70bf7ed90b457d7721d36a4d8ff8535b4b3993df Mon Sep 17 00:00:00 2001 From: Akash Satheesan Date: Mon, 3 May 2021 20:37:01 +0530 Subject: [PATCH] fix(lib/vscode): fix terminal channel --- lib/vscode/src/vs/server/node/channel.ts | 55 +++++++++++++++--------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/lib/vscode/src/vs/server/node/channel.ts b/lib/vscode/src/vs/server/node/channel.ts index c9a4b343..01faa6b9 100644 --- a/lib/vscode/src/vs/server/node/channel.ts +++ b/lib/vscode/src/vs/server/node/channel.ts @@ -43,7 +43,7 @@ import { ExtensionScanner, ExtensionScannerInput } from 'vs/workbench/services/e class Watcher extends DiskFileSystemProvider { public readonly watches = new Map(); - public dispose(): void { + public override dispose(): void { this.watches.forEach((w) => w.dispose()); this.watches.clear(); super.dispose(); @@ -263,6 +263,7 @@ export class ExtensionEnvironmentChannel implements IServerChannel { globalStorageHome: this.environment.globalStorageHome, workspaceStorageHome: this.environment.workspaceStorageHome, userHome: this.environment.userHome, + useHostProxy: false, os: platform.OS, marks: [] }; @@ -382,7 +383,7 @@ class VariableResolverService extends AbstractVariableResolverService { getLineNumber: (): string | undefined => { return args.resolvedVariables.selectedText; }, - }, undefined, env); + }, undefined, Promise.resolve(env)); } } @@ -442,6 +443,7 @@ class Terminal extends TerminalProcess { workspaceId: this.workspaceId, workspaceName: this.workspaceName, isOrphan: this.isOrphan, + icon: 'bash' // TODO@oxy: used for icon, but not sure how to resolve it }; } } @@ -472,8 +474,7 @@ export class TerminalProviderChannel implements IServerChannel { - // TODO: Not sure what sync means. - this._onProcessData.fire({ id, event: { data, sync: true }}); + this._onProcessData.fire({ id, event: data }); }); public constructor (private readonly logService: ILogService) {} @@ -514,7 +515,7 @@ export class TerminalProviderChannel implements IServerChannel resources.joinPath(activeWorkspaceUri, relativePath), } : undefined; - const resolverService = new VariableResolverService(remoteAuthority, args, process.env as platform.IProcessEnvironment); - const resolver = terminalEnvironment.createVariableResolver(activeWorkspace, resolverService); + const resolverService = new VariableResolverService(remoteAuthority, args, process.env); + const resolver = terminalEnvironment.createVariableResolver(activeWorkspace, process.env, resolverService); const getDefaultShellAndArgs = async (): Promise<{ executable: string; args: string[] | string }> => { if (shellLaunchConfig.executable) { - const executable = resolverService.resolve(activeWorkspace, shellLaunchConfig.executable); + const executable = await resolverService.resolveAsync(activeWorkspace, shellLaunchConfig.executable); let resolvedArgs: string[] | string = []; if (shellLaunchConfig.args && Array.isArray(shellLaunchConfig.args)) { for (const arg of shellLaunchConfig.args) { - resolvedArgs.push(resolverService.resolve(activeWorkspace, arg)); + resolvedArgs.push(await resolverService.resolveAsync(activeWorkspace, arg)); } } else if (shellLaunchConfig.args) { - resolvedArgs = resolverService.resolve(activeWorkspace, shellLaunchConfig.args); + resolvedArgs = await resolverService.resolveAsync(activeWorkspace, shellLaunchConfig.args); } return { executable, args: resolvedArgs }; } const executable = terminalEnvironment.getDefaultShell( (key) => args.configuration[key], - args.isWorkspaceShellAllowed, - await getSystemShell(platform.platform, process.env as platform.IProcessEnvironment), + await getSystemShell(platform.OS, process.env as platform.IProcessEnvironment), process.env.hasOwnProperty('PROCESSOR_ARCHITEW6432'), process.env.windir, resolver, @@ -594,7 +597,6 @@ export class TerminalProviderChannel implements IServerChannel args.configuration[key], - args.isWorkspaceShellAllowed, false, // useAutomationShell resolver, this.logService, @@ -625,7 +627,7 @@ export class TerminalProviderChannel implements IServerChannel => { + const getEnvFromConfig = (): ITerminalEnvironment => { if (platform.isWindows) { return args.configuration['terminal.integrated.env.windows']; } else if (platform.isMacintosh) { @@ -635,7 +637,7 @@ export class TerminalProviderChannel implements IServerChannel => { - const env = await getMainProcessParentEnv(); + const env = await getMainProcessParentEnv(process.env); env.VSCODE_IPC_HOOK_CLI = process.env['VSCODE_IPC_HOOK_CLI']!; return env; }; @@ -644,7 +646,6 @@ export class TerminalProviderChannel implements IServerChannel { + private async attachToProcess(_id: number): Promise { // TODO: Won't be necessary until we have persistent terminals. throw new Error('not implemented'); } @@ -743,8 +744,14 @@ export class TerminalProviderChannel implements IServerChannel { - // TODO: reduceGraceTime. + private async reduceConnectionGraceTime(): Promise { + // NOTE: Not required unless we implement orphan terminals, see above. + // Returning instead of throwing error as VSCode expects this function + // to always succeed and throwing an error causes the terminal to crash. + return; + } + + private async listProcesses(): Promise { const terminals = await Promise.all(Array.from(this.terminals).map(async ([id, terminal]) => { return terminal.description(id); })); @@ -786,6 +793,14 @@ export class TerminalProviderChannel implements IServerChannel { + return { ...process.env }; + } + + async getDefaultSystemShell(osOverride: platform.OperatingSystem = platform.OS): Promise { + return getSystemShell(osOverride, process.env); + } } function transformIncoming(remoteAuthority: string, uri: UriComponents | undefined): URI | undefined {