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

Commit

Permalink
Allow dismissing of warning for goreturns
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a committed Jun 26, 2019
1 parent 72d7458 commit 658db8d
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/goModules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ export async function getModFolderPath(fileuri: vscode.Uri): Promise<string> {
}
if (goConfig['useLanguageServer'] === false) {
const promptMsg = 'To get better performance during code completion, please update to use the language server from Google';
const choseToUpdateLS = await promptToUpdateToolForModules('gopls', promptMsg);
const choseToUpdateLS = await promptToUpdateToolForModules('gopls', promptMsg, goConfig);
promptFormatTool = promptFormatTool && !choseToUpdateLS;
} else if (promptFormatTool) {
const languageServerExperimentalFeatures: any = goConfig.get('languageServerExperimentalFeatures');
promptFormatTool = languageServerExperimentalFeatures['format'] === false;
}

if (promptFormatTool) {
goConfig.update('formatTool', 'goimports', vscode.ConfigurationTarget.WorkspaceFolder);
vscode.window.showInformationMessage('`goreturns` doesnt support auto-importing missing imports when using Go modules yet. So updating the "formatTool" setting to `goimports` for this workspace.');
const promptMsgForFormatTool = '`goreturns` doesnt support auto-importing missing imports when using Go modules yet. Please update the "formatTool" setting to `goimports`.';
await promptToUpdateToolForModules('switchFormatToolToGoimports', promptMsgForFormatTool, goConfig);
}
}
packageModCache.set(pkgPath, goModEnvResult);
Expand All @@ -87,7 +87,7 @@ function logModuleUsage() {
}

const promptedToolsForCurrentSession = new Set<string>();
export async function promptToUpdateToolForModules(tool: string, promptMsg: string): Promise<boolean> {
export async function promptToUpdateToolForModules(tool: string, promptMsg: string, goConfig?: vscode.WorkspaceConfiguration): Promise<boolean> {
if (promptedToolsForCurrentSession.has(tool)) {
return false;
}
Expand All @@ -105,10 +105,15 @@ export async function promptToUpdateToolForModules(tool: string, promptMsg: stri
switch (selected) {
case 'Update':
choseToUpdate = true;
if (!goConfig) {
goConfig = vscode.workspace.getConfiguration('go');
}
if (tool === 'switchFormatToolToGoimports') {
goConfig.update('formatTool', 'goimports', vscode.ConfigurationTarget.Global);
} else {
installTools([tool], goVersion)
.then(() => {
if (tool === 'gopls') {
const goConfig = vscode.workspace.getConfiguration('go');
if (goConfig.get('useLanguageServer') === false) {
goConfig.update('useLanguageServer', true, vscode.ConfigurationTarget.Global);
}
Expand All @@ -118,6 +123,7 @@ export async function promptToUpdateToolForModules(tool: string, promptMsg: stri
vscode.window.showInformationMessage('Reload VS Code window to enable the use of Go language server');
}
});
}
promptedToolsForModules[tool] = true;
updateGlobalState('promptedToolsForModules', promptedToolsForModules);
break;
Expand Down

0 comments on commit 658db8d

Please sign in to comment.