Skip to content

Commit da69936

Browse files
committed
only create output channel when needed
1 parent c6c2abf commit da69936

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
"commands": [
4444
{
4545
"command": "tailwindCSS.showOutput",
46-
"title": "Tailwind CSS: Show Output"
46+
"title": "Tailwind CSS: Show Output",
47+
"enablement": "tailwindCSS.hasOutputChannel"
4748
}
4849
],
4950
"grammars": [

src/extension.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,13 @@ function getUserLanguages(folder?: WorkspaceFolder): Record<string, string> {
8585

8686
export function activate(context: ExtensionContext) {
8787
let module = context.asAbsolutePath(path.join('dist', 'server', 'index.js'))
88-
let outputChannel: OutputChannel = Window.createOutputChannel(CLIENT_NAME)
88+
let outputChannel: OutputChannel
8989

9090
context.subscriptions.push(
9191
commands.registerCommand('tailwindCSS.showOutput', () => {
92-
outputChannel.show()
92+
if (outputChannel) {
93+
outputChannel.show()
94+
}
9395
})
9496
)
9597

@@ -155,6 +157,11 @@ export function activate(context: ExtensionContext) {
155157
)
156158
}
157159

160+
if (!outputChannel) {
161+
outputChannel = Window.createOutputChannel(CLIENT_NAME)
162+
commands.executeCommand('setContext', 'tailwindCSS.hasOutputChannel', true)
163+
}
164+
158165
let serverOptions: ServerOptions = {
159166
run: { module, transport: TransportKind.ipc },
160167
debug: {

0 commit comments

Comments
 (0)