From 2e5b265e00417dde0fea453eb8abdd34a8ec7d2c Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Fri, 24 Apr 2020 06:54:06 -0700 Subject: [PATCH] Add clear command and update to use new api --- terminal-sample/package.json | 7 ++++++- terminal-sample/src/extension.ts | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/terminal-sample/package.json b/terminal-sample/package.json index 84607311..27caa13d 100644 --- a/terminal-sample/package.json +++ b/terminal-sample/package.json @@ -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" } ] }, diff --git a/terminal-sample/src/extension.ts b/terminal-sample/src/extension.ts index 2e605f77..17a370ea 100644 --- a/terminal-sample/src/extension.ts +++ b/terminal-sample/src/extension.ts @@ -146,10 +146,15 @@ export function activate(context: vscode.ExtensionContext) { })); context.subscriptions.push(vscode.commands.registerCommand('terminalTest.updateEnvironment', () => { - const collection = (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 {