Files
azuredatastudio/extensions/git/src/terminal.ts
Karl Burtram e7d3d047ec Merge from vscode merge-base (#22780)
* Revert "Revert "Merge from vscode merge-base (#22769)" (#22779)"

This reverts commit 47a1745180.

* Fix notebook download task

* Remove done call from extensions-ci
2023-04-19 21:48:46 -07:00

45 lines
1.4 KiB
TypeScript

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ExtensionContext, workspace } from 'vscode';
import { filterEvent, IDisposable } from './util';
export interface ITerminalEnvironmentProvider {
getTerminalEnv(): { [key: string]: string };
}
export class TerminalEnvironmentManager {
private readonly disposable: IDisposable;
constructor(private readonly context: ExtensionContext, private readonly envProviders: (ITerminalEnvironmentProvider | undefined)[]) {
this.disposable = filterEvent(workspace.onDidChangeConfiguration, e => e.affectsConfiguration('git'))
(this.refresh, this);
this.refresh();
}
private refresh(): void {
const config = workspace.getConfiguration('git', null);
this.context.environmentVariableCollection.clear();
if (!config.get<boolean>('enabled', true)) {
return;
}
for (const envProvider of this.envProviders) {
const terminalEnv = envProvider?.getTerminalEnv() ?? {};
for (const name of Object.keys(terminalEnv)) {
this.context.environmentVariableCollection.replace(name, terminalEnv[name]);
}
}
}
dispose(): void {
this.disposable.dispose();
}
}