From da69936f1170558fd9174cd238aca6b47bdef286 Mon Sep 17 00:00:00 2001 From: Brad Cornes Date: Tue, 4 May 2021 15:05:52 +0100 Subject: [PATCH] only create output channel when needed --- package.json | 3 ++- src/extension.ts | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 96f7d1b..8bd1d61 100755 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "commands": [ { "command": "tailwindCSS.showOutput", - "title": "Tailwind CSS: Show Output" + "title": "Tailwind CSS: Show Output", + "enablement": "tailwindCSS.hasOutputChannel" } ], "grammars": [ diff --git a/src/extension.ts b/src/extension.ts index 11058ef..9142097 100755 --- a/src/extension.ts +++ b/src/extension.ts @@ -85,11 +85,13 @@ function getUserLanguages(folder?: WorkspaceFolder): Record { export function activate(context: ExtensionContext) { let module = context.asAbsolutePath(path.join('dist', 'server', 'index.js')) - let outputChannel: OutputChannel = Window.createOutputChannel(CLIENT_NAME) + let outputChannel: OutputChannel context.subscriptions.push( commands.registerCommand('tailwindCSS.showOutput', () => { - outputChannel.show() + if (outputChannel) { + outputChannel.show() + } }) ) @@ -155,6 +157,11 @@ export function activate(context: ExtensionContext) { ) } + if (!outputChannel) { + outputChannel = Window.createOutputChannel(CLIENT_NAME) + commands.executeCommand('setContext', 'tailwindCSS.hasOutputChannel', true) + } + let serverOptions: ServerOptions = { run: { module, transport: TransportKind.ipc }, debug: {