From bf2ce37f143ee136a471065af6904cbeb3707090 Mon Sep 17 00:00:00 2001 From: Hana Date: Mon, 6 Dec 2021 18:37:03 -0500 Subject: [PATCH] src/goDebugConfiguration.ts: allow users to debug with older versions of dlv-dap Delve DAP has been stable for a while so using an old version of dlv-dap is not too much of concern. We still prompt to update dlv-dap but we no longer stop users who decided not to update right now. Fixes golang/vscode-go#1814 Change-Id: Ieb8fa62833a7f901c242e36a261c613bda5e24f1 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/369753 Trust: Hyang-Ah Hana Kim Run-TryBot: Hyang-Ah Hana Kim TryBot-Result: kokoro Reviewed-by: Polina Sokolova --- src/goDebugConfiguration.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/goDebugConfiguration.ts b/src/goDebugConfiguration.ts index cb130fa74c..bf2b1eb4eb 100644 --- a/src/goDebugConfiguration.ts +++ b/src/goDebugConfiguration.ts @@ -10,6 +10,7 @@ import { lstatSync } from 'fs'; import path = require('path'); import vscode = require('vscode'); +import { ContinuedEvent } from 'vscode-debugadapter'; import { getGoConfig } from './config'; import { toolExecutionEnvironment } from './goEnv'; import { @@ -27,7 +28,7 @@ import { getBinPath, getGoVersion } from './util'; import { parseEnvFiles } from './utils/envUtils'; import { resolveHomeDir } from './utils/pathUtils'; -let dlvDAPVersionCurrent = false; +let dlvDAPVersionChecked = false; export class GoDebugConfigurationProvider implements vscode.DebugConfigurationProvider { constructor(private defaultDebugAdapterType: string = 'go') {} @@ -265,7 +266,7 @@ export class GoDebugConfigurationProvider implements vscode.DebugConfigurationPr } debugConfiguration['dlvToolPath'] = dlvToolPath; - if (debugAdapter === 'dlv-dap' && !dlvDAPVersionCurrent) { + if (debugAdapter === 'dlv-dap' && !dlvDAPVersionChecked) { const tool = getToolAtVersion('dlv-dap'); if (await shouldUpdateTool(tool, dlvToolPath)) { // If the user has opted in to automatic tool updates, we can update @@ -276,13 +277,13 @@ export class GoDebugConfigurationProvider implements vscode.DebugConfigurationPr const toolVersion = { ...tool, version: tool.latestVersion }; // ToolWithVersion await installTools([toolVersion], goVersion, true); } else { - // If we are prompting the user to update, we do not want to continue - // with this debug session. - promptForUpdatingTool(tool.name); - return; + await promptForUpdatingTool(tool.name); } + // installTools could've failed (e.g. no network access) or the user decliend to install dlv-dap + // in promptForUpdatingTool. If dlv-dap doesn't exist or dlv-dap is too old to have MVP features, + // the failure will be visible to users when launching the dlv-dap process (crash or error message). } - dlvDAPVersionCurrent = true; + dlvDAPVersionChecked = true; } if (debugConfiguration['mode'] === 'auto') {