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

Commit 3c25385

Browse files
authoredAug 28, 2016
Merge pull request #458 from ramya-rao-a/ramya-rao-a/update-on-config-change
Update GoRoot,GoPath env variables when config changes. Fixes #455
2 parents 48ca96f + 783bb35 commit 3c25385

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed
 

‎src/goInstallTools.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export function installTools(missing: string[]) {
8181
});
8282
}
8383

84-
export function setupGoPathAndOfferToInstallTools() {
84+
export function updateGoPathGoRootFromConfig() {
8585
let goroot = vscode.workspace.getConfiguration('go')['goroot'];
8686
if (goroot) {
8787
process.env['GOROOT'] = goroot;
@@ -90,7 +90,12 @@ export function setupGoPathAndOfferToInstallTools() {
9090
let gopath = vscode.workspace.getConfiguration('go')['gopath'];
9191
if (gopath) {
9292
process.env['GOPATH'] = gopath.replace(/\${workspaceRoot}/g, vscode.workspace.rootPath);
93+
hideGoStatus();
9394
}
95+
}
96+
97+
export function setupGoPathAndOfferToInstallTools() {
98+
updateGoPathGoRootFromConfig();
9499

95100
if (!process.env['GOPATH']) {
96101
let info = 'GOPATH is not set as an environment variable or via `go.gopath` setting in Code';

‎src/goMain.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { GoSignatureHelpProvider } from './goSignature';
2020
import { GoWorkspaceSymbolProvider } from './goSymbol';
2121
import { GoCodeActionProvider } from './goCodeAction';
2222
import { check, ICheckResult } from './goCheck';
23-
import { setupGoPathAndOfferToInstallTools } from './goInstallTools';
23+
import { updateGoPathGoRootFromConfig, setupGoPathAndOfferToInstallTools } from './goInstallTools';
2424
import { GO_MODE } from './goMode';
2525
import { showHideStatus } from './goStatus';
2626
import { coverageCurrentPackage, getCodeCoverage, removeCodeCoverage } from './goCover';
@@ -84,6 +84,10 @@ export function activate(ctx: vscode.ExtensionContext): void {
8484
installAllTools();
8585
}));
8686

87+
ctx.subscriptions.push(vscode.workspace.onDidChangeConfiguration(() => {
88+
updateGoPathGoRootFromConfig();
89+
}));
90+
8791
vscode.languages.setLanguageConfiguration(GO_MODE.language, {
8892
indentationRules: {
8993
// ^(.*\*/)?\s*\}.*$

‎src/goStatus.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ export function showHideStatus() {
2828
}
2929

3030
export function hideGoStatus() {
31-
statusBarEntry.dispose();
31+
if (statusBarEntry) {
32+
statusBarEntry.dispose();
33+
}
3234
}
3335

3436
export function showGoStatus(message: string, command: string, tooltip?: string) {

0 commit comments

Comments
 (0)