Skip to content

Commit

Permalink
Prompt to update tools when goroot changes Fixes golang#1286
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a committed Dec 5, 2017
1 parent 9f2e66d commit d19267c
Showing 1 changed file with 28 additions and 16 deletions.
44 changes: 28 additions & 16 deletions src/goMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,36 @@ export function activate(ctx: vscode.ExtensionContext): void {
let langServerFlags: string[] = vscode.workspace.getConfiguration('go')['languageServerFlags'] || [];

updateGoPathGoRootFromConfig().then(() => {
getGoVersion().then(currentVersion => {
if (currentVersion) {
const prevVersion = ctx.globalState.get('goVersion');
const currVersionString = `${currentVersion.major}.${currentVersion.minor}`;

if (prevVersion !== currVersionString) {
if (prevVersion) {
const updateToolsCmdText = 'Update tools';
vscode.window.showInformationMessage('Your Go version is different than before, few Go tools may need re-compiling', updateToolsCmdText).then(selected => {
if (selected === updateToolsCmdText) {
vscode.commands.executeCommand('go.tools.install');
}
});
const updateToolsCmdText = 'Update tools';
const prevGoroot = ctx.globalState.get('goroot');
const currentGoroot = process.env['GOROOT'];
if (prevGoroot !== currentGoroot && prevGoroot) {
vscode.window.showInformationMessage('Your goroot is different than before, few Go tools may need re-compiling', updateToolsCmdText).then(selected => {
if (selected === updateToolsCmdText) {
vscode.commands.executeCommand('go.tools.install');
}
});
} else {
getGoVersion().then(currentVersion => {
if (currentVersion) {
const prevVersion = ctx.globalState.get('goVersion');
const currVersionString = `${currentVersion.major}.${currentVersion.minor}`;

if (prevVersion !== currVersionString) {
if (prevVersion) {
vscode.window.showInformationMessage('Your Go version is different than before, few Go tools may need re-compiling', updateToolsCmdText).then(selected => {
if (selected === updateToolsCmdText) {
vscode.commands.executeCommand('go.tools.install');
}
});
}
ctx.globalState.update('goVersion', currVersionString);
}
ctx.globalState.update('goVersion', currVersionString);
}
}
});
});
}
ctx.globalState.update('goroot', currentGoroot);

offerToInstallTools();
let langServerAvailable = checkLanguageServer();
if (langServerAvailable) {
Expand Down

0 comments on commit d19267c

Please sign in to comment.