Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
Status bar item for Modules usage
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a committed Jul 26, 2019
1 parent 4b516f9 commit 1dd40da
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
5 changes: 5 additions & 0 deletions src/goMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,11 @@ export function activate(ctx: vscode.ExtensionContext): void {

initCoverageDecorators(ctx);

ctx.subscriptions.push(vscode.commands.registerCommand('go.open.modulewiki', async () => {
vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://github.com/microsoft/vscode-go/wiki/Go-modules-support-in-Visual-Studio-Code'));
}));
showHideStatus(vscode.window.activeTextEditor);

const testCodeLensProvider = new GoRunTestCodeLensProvider();
const referencesCodeLensProvider = new GoReferencesCodeLensProvider();

Expand Down
34 changes: 22 additions & 12 deletions src/goStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,36 @@

import { GO_MODE } from './goMode';
import vscode = require('vscode');
import { isModSupported } from './goModules';

export let outputChannel = vscode.window.createOutputChannel('Go');

export let diagnosticsStatusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);

let statusBarEntry: vscode.StatusBarItem;
const statusBarItemModule = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
statusBarItemModule.text = '$(megaphone) Go Modules';
statusBarItemModule.tooltip = 'Modules is enabled for this project. Click to learn more about Modules support in VS Code.';
statusBarItemModule.command = 'go.open.modulewiki';

export function showHideStatus() {
if (!statusBarEntry) {
return;
}
if (!vscode.window.activeTextEditor) {
statusBarEntry.hide();
return;
}
if (vscode.languages.match(GO_MODE, vscode.window.activeTextEditor.document)) {
statusBarEntry.show();
return;
export function showHideStatus(editor: vscode.TextEditor) {
if (statusBarEntry) {
if (!editor) {
statusBarEntry.hide();
} else if (vscode.languages.match(GO_MODE, editor.document)) {
statusBarEntry.show();
} else {
statusBarEntry.hide();
}
}
statusBarEntry.hide();

isModSupported(editor.document.uri).then(isMod => {
if (isMod) {
statusBarItemModule.show();
} else {
statusBarItemModule.hide();
}
});
}

export function hideGoStatus() {
Expand Down

0 comments on commit 1dd40da

Please sign in to comment.