Add clear command and update to use new api

This commit is contained in:
Daniel Imms
2020-04-24 06:54:06 -07:00
parent 8fcd5a3830
commit 2e5b265e00
2 changed files with 12 additions and 2 deletions

View File

@ -27,7 +27,8 @@
"onCommand:terminalTest.show",
"onCommand:terminalTest.showPreserveFocus",
"onCommand:terminalTest.terminals",
"onCommand:terminalTest.updateEnvironment"
"onCommand:terminalTest.updateEnvironment",
"onCommand:terminalTest.clearEnvironment"
],
"main": "./out/extension.js",
"contributes": {
@ -95,6 +96,10 @@
{
"command": "terminalTest.updateEnvironment",
"title": "Terminal API: Update environment"
},
{
"command": "terminalTest.clearEnvironment",
"title": "Terminal API: Clear environment"
}
]
},

View File

@ -146,10 +146,15 @@ export function activate(context: vscode.ExtensionContext) {
}));
context.subscriptions.push(vscode.commands.registerCommand('terminalTest.updateEnvironment', () => {
const collection = (<any>vscode.window).getEnvironmentVariableCollection();
const collection = (context as any).environmentVariableCollection;
collection.replace('FOO', 'BAR');
collection.append('PATH', '/test/path');
}));
context.subscriptions.push(vscode.commands.registerCommand('terminalTest.clearEnvironment', () => {
const collection = (context as any).environmentVariableCollection;
collection.clear();
}));
}
function colorText(text: string): string {