From 85debee782a4cf583f4086c8a9cfffa92bd5c654 Mon Sep 17 00:00:00 2001 From: "David L. Day" <1132144+davidlday@users.noreply.github.com> Date: Sun, 22 Sep 2024 13:33:29 -0400 Subject: [PATCH] fix: status bar visibilitiy (#770) --- src/Linter.ts | 14 ++++++++------ src/extension.ts | 7 ++++++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Linter.ts b/src/Linter.ts index a75a1fb1..3e09b002 100644 --- a/src/Linter.ts +++ b/src/Linter.ts @@ -138,10 +138,11 @@ export class Linter implements CodeActionProvider { // Editor Changed public editorChanged(editor: TextEditor | undefined, lint: boolean): void { - if (editor) { - this.documentChanged(editor.document, lint); - } else { + if (!editor) { this.statusBarManager.hide(); + return; + } else { + this.documentChanged(editor.document, lint); } } @@ -150,7 +151,10 @@ export class Linter implements CodeActionProvider { document: TextDocument | undefined, lint: boolean, ): void { - if (document) { + if (!document) { + this.statusBarManager.hide(); + return; + } else { if (this.configManager.isSupportedDocument(document)) { this.statusBarManager.show(); if (lint) { @@ -159,8 +163,6 @@ export class Linter implements CodeActionProvider { } this.requestLint(document); } - } else { - this.statusBarManager.hide(); } } } diff --git a/src/extension.ts b/src/extension.ts index 056d8599..69c7b108 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -69,7 +69,12 @@ export function activate(context: vscode.ExtensionContext): void { // Register onDidChangeActiveTextEditor event - request lint context.subscriptions.push( vscode.window.onDidChangeActiveTextEditor((editor) => { - linter.editorChanged(editor, configMan.isLintOnChange()); + if (editor !== undefined) { + linter.editorChanged( + vscode.window.activeTextEditor, + configMan.isLintOnChange(), + ); + } }), );