mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-31 09:10:30 -04:00
Merge from vscode 1ec43773e37997841c5af42b33ddb180e9735bf2
This commit is contained in:
@@ -23,6 +23,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
|
||||
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { withNullAsUndefined } from 'vs/base/common/types';
|
||||
import { IEnvironmentVariableService, IMergedEnvironmentVariableCollection } from 'vs/workbench/contrib/terminal/common/environmentVariable';
|
||||
|
||||
/** The amount of time to consider terminal errors to be related to the launch */
|
||||
const LAUNCHING_DURATION = 500;
|
||||
@@ -59,6 +60,7 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce
|
||||
private _latency: number = -1;
|
||||
private _latencyLastMeasured: number = 0;
|
||||
private _initialCwd: string | undefined;
|
||||
private _extEnvironmentVariableCollection: IMergedEnvironmentVariableCollection | undefined;
|
||||
|
||||
private readonly _onProcessReady = this._register(new Emitter<void>());
|
||||
public get onProcessReady(): Event<void> { return this._onProcessReady.event; }
|
||||
@@ -87,7 +89,8 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce
|
||||
@IWorkbenchEnvironmentService private readonly _environmentService: IWorkbenchEnvironmentService,
|
||||
@IProductService private readonly _productService: IProductService,
|
||||
@ITerminalInstanceService private readonly _terminalInstanceService: ITerminalInstanceService,
|
||||
@IRemoteAgentService private readonly _remoteAgentService: IRemoteAgentService
|
||||
@IRemoteAgentService private readonly _remoteAgentService: IRemoteAgentService,
|
||||
@IEnvironmentVariableService private readonly _environmentVariableService: IEnvironmentVariableService
|
||||
) {
|
||||
super();
|
||||
this.ptyProcessReady = new Promise<void>(c => {
|
||||
@@ -230,6 +233,11 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce
|
||||
const baseEnv = this._configHelper.config.inheritEnv ? processEnv : await this._terminalInstanceService.getMainProcessParentEnv();
|
||||
const env = terminalEnvironment.createTerminalEnvironment(shellLaunchConfig, lastActiveWorkspace, envFromConfigValue, this._configurationResolverService, isWorkspaceShellAllowed, this._productService.version, this._configHelper.config.detectLocale, baseEnv);
|
||||
|
||||
// Fetch any extension environment additions and apply them
|
||||
this._extEnvironmentVariableCollection = this._environmentVariableService.mergedCollection;
|
||||
this._register(this._environmentVariableService.onDidChangeCollections(newCollection => this._onEnvironmentVariableCollectionChange(newCollection)));
|
||||
this._extEnvironmentVariableCollection.applyToProcessEnvironment(env);
|
||||
|
||||
const useConpty = this._configHelper.config.windowsEnableConpty && !isScreenReaderModeEnabled;
|
||||
return this._terminalInstanceService.createTerminalProcess(shellLaunchConfig, initialCwd, cols, rows, env, useConpty);
|
||||
}
|
||||
@@ -304,4 +312,37 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce
|
||||
|
||||
this._onProcessExit.fire(exitCode);
|
||||
}
|
||||
|
||||
private _onEnvironmentVariableCollectionChange(newCollection: IMergedEnvironmentVariableCollection): void {
|
||||
// TODO: React to changes in environment variable collections
|
||||
// const newAdditions = this._extEnvironmentVariableCollection!.getNewAdditions(newCollection);
|
||||
// if (newAdditions === undefined) {
|
||||
// return;
|
||||
// }
|
||||
// const promptChoices: IPromptChoice[] = [
|
||||
// {
|
||||
// label: nls.localize('apply', "Apply"),
|
||||
// run: () => {
|
||||
// let text = '';
|
||||
// newAdditions.forEach((mutator, variable) => {
|
||||
// // TODO: Support other common shells
|
||||
// // TODO: Escape the new values properly
|
||||
// switch (mutator.type) {
|
||||
// case EnvironmentVariableMutatorType.Append:
|
||||
// text += `export ${variable}="$${variable}${mutator.value}"\n`;
|
||||
// break;
|
||||
// case EnvironmentVariableMutatorType.Prepend:
|
||||
// text += `export ${variable}="${mutator.value}$${variable}"\n`;
|
||||
// break;
|
||||
// case EnvironmentVariableMutatorType.Replace:
|
||||
// text += `export ${variable}="${mutator.value}"\n`;
|
||||
// break;
|
||||
// }
|
||||
// });
|
||||
// this.write(text);
|
||||
// }
|
||||
// } as IPromptChoice
|
||||
// ];
|
||||
// this._notificationService.prompt(Severity.Info, nls.localize('environmentchange', "An extension wants to change the terminal environment, do you want to send commands to set the variables in the terminal? Note if you have an application open in the terminal this may not work."), promptChoices);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user