Skip to content

Commit 6f67a37

Browse files
committed
[release] src/goDebugConfiguration.ts: add resolveDebugConfiguration back
https://go-review.googlesource.com/c/vscode-go/+/248659 replaced resolveDebugConfiguration with resolveDebugConfigurationWithSubstitutedVariables in order to resolve the envFile correctly in case the property requires substitution. I thought, when debug is requested without launch.json, the default debugConfiguration provided by provideDebugConfiguration would be used and eventually resolveDebugConfigurationWithSubstitutedVariables would be called to process it further. However, it doesn't seem that's the case. Instead, I observed, resolveDebugConfiguration is called first with an empty debugConfiguration and VS Code just drops the launch request without calling resolveDebugConfigurationWithSubstitutedVariables at all. We still need to implement resolveDebugConfiguration and let it populate the debugConfiguration. Fixes #640 Change-Id: I693c19df1a47cb1011cccdd2f582b4cf3c0fc2ab Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/254843 Trust: Hyang-Ah Hana Kim <[email protected]> Run-TryBot: Hyang-Ah Hana Kim <[email protected]> TryBot-Result: kokoro <[email protected]> Reviewed-by: Suzy Mueller <[email protected]> (cherry picked from commit 59858d7) Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/255117
1 parent be02aa1 commit 6f67a37

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

src/goDebugConfiguration.ts

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class GoDebugConfigurationProvider implements vscode.DebugConfigurationPr
3434
];
3535
}
3636

37-
public resolveDebugConfigurationWithSubstitutedVariables(
37+
public resolveDebugConfiguration(
3838
folder: vscode.WorkspaceFolder | undefined,
3939
debugConfiguration: vscode.DebugConfiguration,
4040
token?: vscode.CancellationToken
@@ -62,9 +62,6 @@ export class GoDebugConfigurationProvider implements vscode.DebugConfigurationPr
6262
debugConfiguration['packagePathToGoModPathMap'] = packagePathToGoModPathMap;
6363

6464
const goConfig = getGoConfig(folder && folder.uri);
65-
66-
combineEnvFilesAndEnv(folder, debugConfiguration);
67-
6865
const dlvConfig = goConfig.get<any>('delveConfig');
6966
let useApiV1 = false;
7067
if (debugConfiguration.hasOwnProperty('useApiV1')) {
@@ -126,6 +123,26 @@ export class GoDebugConfigurationProvider implements vscode.DebugConfigurationPr
126123
return debugConfiguration;
127124
}
128125

126+
public resolveDebugConfigurationWithSubstitutedVariables(
127+
folder: vscode.WorkspaceFolder | undefined,
128+
debugConfiguration: vscode.DebugConfiguration,
129+
token?: vscode.CancellationToken
130+
): vscode.DebugConfiguration {
131+
// Reads debugConfiguration.envFile and
132+
// combines the environment variables from all the env files and
133+
// debugConfiguration.env, on top of the tools execution environment variables.
134+
// It also unsets 'envFile' from the user-suppled debugConfiguration
135+
// because it is already applied.
136+
const goToolsEnvVars = toolExecutionEnvironment(folder?.uri); // also includes GOPATH: getCurrentGoPath().
137+
const fileEnvs = parseEnvFiles(debugConfiguration['envFile']);
138+
const env = debugConfiguration['env'] || {};
139+
140+
debugConfiguration['env'] = Object.assign(goToolsEnvVars, fileEnvs, env);
141+
debugConfiguration['envFile'] = undefined; // unset, since we already processed.
142+
143+
return debugConfiguration;
144+
}
145+
129146
private showWarning(ignoreWarningKey: string, warningMessage: string) {
130147
const ignoreWarning = getFromGlobalState(ignoreWarningKey);
131148
if (ignoreWarning) {
@@ -140,18 +157,3 @@ export class GoDebugConfigurationProvider implements vscode.DebugConfigurationPr
140157
});
141158
}
142159
}
143-
144-
// combineEnvFilesAndEnv reads debugConfiguration.envFile and
145-
// combines the environment variables from all the env files and
146-
// debugConfiguration.env, on top of the tools execution environment variables.
147-
// It also unsets 'envFile' from the user-suppled debugConfiguration
148-
// because it is already applied.
149-
function combineEnvFilesAndEnv(
150-
folder: vscode.WorkspaceFolder, debugConfiguration: vscode.DebugConfiguration) {
151-
const goToolsEnvVars = toolExecutionEnvironment(folder?.uri); // also includes GOPATH: getCurrentGoPath().
152-
const fileEnvs = parseEnvFiles(debugConfiguration['envFile']);
153-
const env = debugConfiguration['env'] || {};
154-
155-
debugConfiguration['env'] = Object.assign(goToolsEnvVars, fileEnvs, env);
156-
debugConfiguration['envFile'] = undefined; // unset, since we already processed.
157-
}

0 commit comments

Comments
 (0)