diff --git a/src/goDebugConfiguration.ts b/src/goDebugConfiguration.ts index 6d5fa13a21..1044788f21 100644 --- a/src/goDebugConfiguration.ts +++ b/src/goDebugConfiguration.ts @@ -11,9 +11,9 @@ import path = require('path'); import vscode = require('vscode'); import { getGoConfig } from './config'; import { toolExecutionEnvironment } from './goEnv'; -import { promptForMissingTool, promptForUpdatingTool, shouldUpdateTool } from './goInstallTools'; +import { declinedToolInstall, promptForMissingTool, promptForUpdatingTool, shouldUpdateTool } from './goInstallTools'; import { packagePathToGoModPathMap } from './goModules'; -import { getToolAtVersion } from './goTools'; +import { getTool, getToolAtVersion } from './goTools'; import { pickProcess, pickProcessByName } from './pickProcess'; import { getFromGlobalState, updateGlobalState } from './stateUtils'; import { getBinPath, resolvePath } from './util'; @@ -233,8 +233,15 @@ export class GoDebugConfigurationProvider implements vscode.DebugConfigurationPr const debugAdapter = debugConfiguration['debugAdapter'] === 'dlv-dap' ? 'dlv-dap' : 'dlv'; const dlvToolPath = getBinPath(debugAdapter); if (!path.isAbsolute(dlvToolPath)) { - await promptForMissingTool(debugAdapter); - return; + const tool = getTool(debugAdapter); + + // If user has not already declined to install this tool, + // prompt for it. Otherwise continue and have the lack of + // dlv binary be caught later. + if (!declinedToolInstall(debugAdapter)) { + await promptForMissingTool(debugAdapter); + return; + } } debugConfiguration['dlvToolPath'] = dlvToolPath; diff --git a/src/goInstallTools.ts b/src/goInstallTools.ts index 197d6e45f7..05f3328370 100644 --- a/src/goInstallTools.ts +++ b/src/goInstallTools.ts @@ -304,11 +304,18 @@ export async function installTool( return result; } +export function declinedToolInstall(toolName: string) { + const tool = getTool(toolName); + + // If user has declined to install this tool, don't prompt for it. + return !!containsTool(declinedInstalls, tool) +} + export async function promptForMissingTool(toolName: string) { const tool = getTool(toolName); // If user has declined to install this tool, don't prompt for it. - if (containsTool(declinedInstalls, tool)) { + if (declinedToolInstall(toolName)) { return; } @@ -338,7 +345,9 @@ export async function promptForMissingTool(toolName: string) { const installOptions = ['Install']; let missing = await getMissingTools(goVersion); if (!containsTool(missing, tool)) { - return; + // If this function has been called, we want to display the prompt whether + // it appears in missing or not. + missing.push(tool); } missing = missing.filter((x) => x === tool || tool.isImportant); if (missing.length > 1) { @@ -558,6 +567,17 @@ function getMissingTools(goVersion: GoVersion): Promise { (tool) => new Promise((resolve, reject) => { const toolPath = getBinPath(tool.name); + if (tool.name === 'dlv-dap') { + // Check if user already has dlv-dap binary. + // If so, it's likely the user may be interested in updating the tool, + // so we should mark it as important and return as a missing tool. + if (path.isAbsolute(toolPath)) { + tool.isImportant = true; + resolve(tool); + return; + } + tool.isImportant = false; + } resolve(path.isAbsolute(toolPath) ? null : tool); }) ) diff --git a/src/goTools.ts b/src/goTools.ts index b88b33317b..8a61b7b118 100644 --- a/src/goTools.ts +++ b/src/goTools.ts @@ -158,6 +158,7 @@ export function getConfiguredTools( // families are 64-bit, so just try to install it and hope for the best. if (process.arch.match(/^(arm64|mips|mipsel|ppc64|s390|s390x|x64)$/)) { maybeAddTool('dlv'); + maybeAddTool('dlv-dap'); } // gocode-gomod needed in go 1.11 & higher