mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-12 22:08:04 -05:00
Merge pull request #184413 from microsoft/tyriar/184331
Adopt EnvironmentVariableCollection in git ext
This commit is contained in:
@@ -18,6 +18,8 @@ export class Askpass implements IIPCHandler, ITerminalEnvironmentProvider {
|
||||
private cache = new Map<string, Credentials>();
|
||||
private credentialsProviders = new Set<CredentialsProvider>();
|
||||
|
||||
readonly featureDescription = 'git auth provider';
|
||||
|
||||
constructor(private ipc?: IIPCServer) {
|
||||
if (ipc) {
|
||||
this.disposable = ipc.registerHandler('askpass', this);
|
||||
|
||||
@@ -17,6 +17,8 @@ export class GitEditor implements IIPCHandler, ITerminalEnvironmentProvider {
|
||||
private env: { [key: string]: string };
|
||||
private disposable: IDisposable = EmptyDisposable;
|
||||
|
||||
readonly featureDescription = 'git editor';
|
||||
|
||||
constructor(ipc?: IIPCServer) {
|
||||
if (ipc) {
|
||||
this.disposable = ipc.registerHandler('git-editor', this);
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ExtensionContext, workspace } from 'vscode';
|
||||
import { ExtensionContext, l10n, workspace } from 'vscode';
|
||||
import { filterEvent, IDisposable } from './util';
|
||||
|
||||
export interface ITerminalEnvironmentProvider {
|
||||
featureDescription?: string;
|
||||
getTerminalEnv(): { [key: string]: string };
|
||||
}
|
||||
|
||||
@@ -29,12 +30,19 @@ export class TerminalEnvironmentManager {
|
||||
return;
|
||||
}
|
||||
|
||||
const features: string[] = [];
|
||||
for (const envProvider of this.envProviders) {
|
||||
const terminalEnv = envProvider?.getTerminalEnv() ?? {};
|
||||
|
||||
for (const name of Object.keys(terminalEnv)) {
|
||||
this.context.environmentVariableCollection.replace(name, terminalEnv[name]);
|
||||
}
|
||||
if (envProvider?.featureDescription && Object.keys(terminalEnv).length > 0) {
|
||||
features.push(envProvider.featureDescription);
|
||||
}
|
||||
}
|
||||
if (features.length) {
|
||||
this.context.environmentVariableCollection.description = l10n.t('Enables the following features: {0}', features.join(', '));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user