[release] src/goStatus: show Go status bar when the extension is enabled

We should be showing the Go status bar, even when there are no
active text editors.

Fixes golang/vscode-go#831

Change-Id: Ifb228b25f64ad41c7b63bdca27cf351768d8c4ce
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/265126
Trust: Suzy Mueller <suzmue@golang.org>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Suzy Mueller <suzmue@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
(cherry picked from commit 5eaf73c4b88bc24173382927ddd99713ed842d55)
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/266577
Reviewed-by: Suzy Mueller <suzmue@golang.org>
diff --git a/src/goInstallTools.ts b/src/goInstallTools.ts
index 691c42b..f5704fa 100644
--- a/src/goInstallTools.ts
+++ b/src/goInstallTools.ts
@@ -16,7 +16,7 @@
 import { getLanguageServerToolPath } from './goLanguageServer';
 import { logVerbose } from './goLogging';
 import { restartLanguageServer } from './goMain';
-import { addGoStatus, initGoEnvStatusBar, outputChannel, removeGoStatus } from './goStatus';
+import { addGoStatus, initGoStatusBar, outputChannel, removeGoStatus } from './goStatus';
 import {
 	containsTool,
 	disableModulesForWildcard,
@@ -414,7 +414,7 @@
 					// clear pre-existing terminal PATH mutation logic set up by this extension.
 					clearGoRuntimeBaseFromPATH();
 				}
-				initGoEnvStatusBar();
+				initGoStatusBar();
 				// TODO: restart language server or synchronize with language server update.
 
 				return resolve();
diff --git a/src/goMain.ts b/src/goMain.ts
index c9843b1..4bae122 100644
--- a/src/goMain.ts
+++ b/src/goMain.ts
@@ -45,7 +45,7 @@
 import { playgroundCommand } from './goPlayground';
 import { GoReferencesCodeLensProvider } from './goReferencesCodelens';
 import { GoRunTestCodeLensProvider } from './goRunTestCodelens';
-import { disposeGoStatusBar, expandGoStatusBar, outputChannel, showHideStatus } from './goStatus';
+import { disposeGoStatusBar, expandGoStatusBar, outputChannel, updateGoStatusBar } from './goStatus';
 import { subTestAtCursor, testAtCursor, testCurrentFile, testCurrentPackage, testPrevious, testWorkspace } from './goTest';
 import { getConfiguredTools } from './goTools';
 import { vetCode } from './goVet';
@@ -589,7 +589,7 @@
 }
 
 function addOnChangeActiveTextEditorListeners(ctx: vscode.ExtensionContext) {
-	[showHideStatus, applyCodeCoverage].forEach((listener) => {
+	[updateGoStatusBar, applyCodeCoverage].forEach((listener) => {
 		// Call the listeners on initilization for current active text editor
 		if (!!vscode.window.activeTextEditor) {
 			listener(vscode.window.activeTextEditor);
diff --git a/src/goStatus.ts b/src/goStatus.ts
index 0009f58..08ec245 100644
--- a/src/goStatus.ts
+++ b/src/goStatus.ts
@@ -25,24 +25,18 @@
 let modulePath: string;
 export const languageServerIcon = '$(zap)';
 
-export function showHideStatus(editor: vscode.TextEditor) {
-	// Update the status bar entry
-	if (!editor) {
-		hideGoStatusBar();
-	} else {
-		showGoStatusBar();
-		// Only update the module path if we are in a Go file.
-		// This allows the user to open output windows without losing
-		// the go.mod information in the status bar.
-		if (isGoFile(editor.document)) {
-			isModSupported(editor.document.uri).then((isMod) => {
-				if (isMod) {
-					getModFolderPath(editor.document.uri).then((p) => modulePath = p);
-				} else {
-					modulePath = '';
-				}
-			});
-		}
+export function updateGoStatusBar(editor: vscode.TextEditor) {
+	// Only update the module path if we are in a Go file.
+	// This allows the user to open output windows without losing
+	// the go.mod information in the status bar.
+	if (!!editor && isGoFile(editor.document)) {
+		isModSupported(editor.document.uri).then((isMod) => {
+			if (isMod) {
+				getModFolderPath(editor.document.uri).then((p) => modulePath = p);
+			} else {
+				modulePath = '';
+			}
+		});
 	}
 }
 
@@ -93,7 +87,7 @@
 /**
  * Initialize the status bar item with current Go binary
  */
-export async function initGoEnvStatusBar() {
+export async function initGoStatusBar() {
 	if (!goEnvStatusbarItem) {
 		goEnvStatusbarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 50);
 	}
@@ -110,7 +104,7 @@
 	const cfg = buildLanguageServerConfig();
 	updateLanguageServerIconGoStatusBar(true, cfg.serverName);
 
-	showHideStatus(vscode.window.activeTextEditor);
+	showGoStatusBar();
 }
 
 export async function updateLanguageServerIconGoStatusBar(started: boolean, server: string) {
@@ -150,21 +144,6 @@
 	if (!!goEnvStatusbarItem) {
 		goEnvStatusbarItem.show();
 	}
-	if (!!statusBarEntry) {
-		statusBarEntry.show();
-	}
-}
-
-/**
- * Hide the Go statusbar items on the statusbar
- */
-export function hideGoStatusBar() {
-	if (!!goEnvStatusbarItem) {
-		goEnvStatusbarItem.hide();
-	}
-	if (!!statusBarEntry) {
-		statusBarEntry.hide();
-	}
 }
 
 export function removeGoStatus() {
@@ -178,5 +157,5 @@
 	statusBarEntry.text = `$(alert) ${message}`;
 	statusBarEntry.command = command;
 	statusBarEntry.tooltip = tooltip;
-	showHideStatus(vscode.window.activeTextEditor);
+	statusBarEntry.show();
 }