From 80ed95c898174f7053d84489ab983fa7a2336498 Mon Sep 17 00:00:00 2001 From: Isaac Poole <55164207+isfopo@users.noreply.github.com> Date: Wed, 10 Jul 2024 22:16:05 -0400 Subject: [PATCH] shows error if key contains spaces --- src/EnvironmentTreeviewProvider.ts | 2 +- src/extension.ts | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/EnvironmentTreeviewProvider.ts b/src/EnvironmentTreeviewProvider.ts index a3850a9..86aa52c 100644 --- a/src/EnvironmentTreeviewProvider.ts +++ b/src/EnvironmentTreeviewProvider.ts @@ -10,7 +10,7 @@ export class EnvironmentTreeviewProvider await vscode.workspace.fs.readFile(element.uri) ); - content = content + `\n${key}=${value}`; + content = content + `\n${key}="${value}"`; vscode.workspace.fs.writeFile( element.uri, diff --git a/src/extension.ts b/src/extension.ts index 26c87b8..0e1b671 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -24,6 +24,11 @@ export function activate(context: vscode.ExtensionContext) { if (!key) { return; + } else if (key.includes(" ")) { + vscode.window.showErrorMessage( + "Environment variable keys cannot contain spaces" + ); + return; } const value = await vscode.window.showInputBox({