Skip to content

Commit

Permalink
regal: when restarting regal, reuse output channel
Browse files Browse the repository at this point in the history
This addresses an issue where the output channel would be recreated many
times as Regal was restarted.

Signed-off-by: Charlie Egan <[email protected]>
  • Loading branch information
charlieegan3 committed Apr 22, 2024
1 parent 51beb9e commit ce68449
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/ls/clients/regal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { execSync } from 'child_process';

let client: LanguageClient;
let clientLock = false;
let outChan: vscode.OutputChannel;

const minimumSupportedRegalVersion = '0.18.0';

Expand Down Expand Up @@ -121,6 +122,10 @@ class debuggableMessageStrategy {
}

export function activateRegal(_context: ExtensionContext) {
if (!outChan) {
outChan = window.createOutputChannel("Regal");
}

// activateRegal is run when the config changes, but this happens a few times
// at startup. We use clientLock to prevent the activation of multiple instances.
if (clientLock) {
Expand Down Expand Up @@ -150,8 +155,6 @@ export function activateRegal(_context: ExtensionContext) {
args: ["language-server"],
};

const outChan = window.createOutputChannel("Regal");

const clientOptions: LanguageClientOptions = {
documentSelector: [{ scheme: 'file', language: 'rego' }],
outputChannel: outChan,
Expand Down

0 comments on commit ce68449

Please sign in to comment.