src/goEnv.ts: pass uri to getGoConfig

The newEnvironment function adds a parameter for uri
so that it can be passed to getGoConfig. This ensures
that the correct toolsEnvVars are provided to commands
that use toolExecutionEnvironment for env values.

Change-Id: I78bb430e8d5a198cefb46103a966f37daefba620
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/388434
Trust: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
Jamal Carvalho 2022-02-28 12:46:40 -05:00
Родитель 0f849d11b0
Коммит 09c4936274
1 изменённых файлов: 3 добавлений и 3 удалений

Просмотреть файл

@ -55,7 +55,7 @@ export function toolInstallationEnvironment(): NodeJS.Dict<string> {
// toolExecutionEnvironment returns the environment in which tools should
// be executed. It always returns a new object.
export function toolExecutionEnvironment(uri?: vscode.Uri, addProcessEnv = true): NodeJS.Dict<string> {
const env = newEnvironment(addProcessEnv);
const env = newEnvironment(uri, addProcessEnv);
const gopath = getCurrentGoPath(uri);
if (gopath) {
env['GOPATH'] = gopath;
@ -69,8 +69,8 @@ export function toolExecutionEnvironment(uri?: vscode.Uri, addProcessEnv = true)
return env;
}
function newEnvironment(addProcessEnv = true): NodeJS.Dict<string> {
const toolsEnvVars = getGoConfig()['toolsEnvVars'];
function newEnvironment(uri?: vscode.Uri, addProcessEnv = true): NodeJS.Dict<string> {
const toolsEnvVars = getGoConfig(uri)['toolsEnvVars'];
const env = addProcessEnv ? Object.assign({}, process.env, toolsEnvVars) : Object.assign({}, toolsEnvVars);
if (toolsEnvVars && typeof toolsEnvVars === 'object') {
Object.keys(toolsEnvVars).forEach(