only create output channel when needed

master
Brad Cornes 2021-05-04 15:05:52 +01:00
parent c6c2abf15e
commit da69936f11
2 changed files with 11 additions and 3 deletions

View File

@ -43,7 +43,8 @@
"commands": [ "commands": [
{ {
"command": "tailwindCSS.showOutput", "command": "tailwindCSS.showOutput",
"title": "Tailwind CSS: Show Output" "title": "Tailwind CSS: Show Output",
"enablement": "tailwindCSS.hasOutputChannel"
} }
], ],
"grammars": [ "grammars": [

View File

@ -85,11 +85,13 @@ function getUserLanguages(folder?: WorkspaceFolder): Record<string, string> {
export function activate(context: ExtensionContext) { export function activate(context: ExtensionContext) {
let module = context.asAbsolutePath(path.join('dist', 'server', 'index.js')) let module = context.asAbsolutePath(path.join('dist', 'server', 'index.js'))
let outputChannel: OutputChannel = Window.createOutputChannel(CLIENT_NAME) let outputChannel: OutputChannel
context.subscriptions.push( context.subscriptions.push(
commands.registerCommand('tailwindCSS.showOutput', () => { 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 = { let serverOptions: ServerOptions = {
run: { module, transport: TransportKind.ipc }, run: { module, transport: TransportKind.ipc },
debug: { debug: {