Skip to content

Commit

Permalink
Log options being passed when using environment collection APIs (#22907)
Browse files Browse the repository at this point in the history
For #22899
  • Loading branch information
Kartik Raj authored Feb 13, 2024
1 parent 5f971ae commit 2dc158e
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions src/client/terminals/envCollectionActivation/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export class TerminalEnvVarCollectionService implements IExtensionActivationServ

// PS1 in some cases is a shell variable (not an env variable) so "env" might not contain it, calculate it in that case.
env.PS1 = await this.getPS1(shell, resource, env);
const prependOptions = await this.getPrependOptions();
const defaultPrependOptions = await this.getPrependOptions();

// Clear any previously set env vars from collection
envVarCollection.clear();
Expand All @@ -213,8 +213,12 @@ export class TerminalEnvVarCollectionService implements IExtensionActivationServ
if (value !== undefined) {
if (key === 'PS1') {
// We cannot have the full PS1 without executing in terminal, which we do not. Hence prepend it.
traceVerbose(`Prepending environment variable ${key} in collection with ${value}`);
envVarCollection.prepend(key, value, prependOptions);
traceVerbose(
`Prepending environment variable ${key} in collection with ${value} ${JSON.stringify(
defaultPrependOptions,
)}`,
);
envVarCollection.prepend(key, value, defaultPrependOptions);
return;
}
if (key === 'PATH') {
Expand All @@ -229,7 +233,11 @@ export class TerminalEnvVarCollectionService implements IExtensionActivationServ
if (deactivate) {
value = `${deactivate}${this.separator}${value}`;
}
traceVerbose(`Prepending environment variable ${key} in collection with ${value}`);
traceVerbose(
`Prepending environment variable ${key} in collection with ${value} ${JSON.stringify(
options,
)}`,
);
envVarCollection.prepend(key, value, options);
} else {
if (!value.endsWith(this.separator)) {
Expand All @@ -238,16 +246,23 @@ export class TerminalEnvVarCollectionService implements IExtensionActivationServ
if (deactivate) {
value = `${deactivate}${this.separator}${value}`;
}
traceVerbose(`Prepending environment variable ${key} in collection to ${value}`);
traceVerbose(
`Prepending environment variable ${key} in collection to ${value} ${JSON.stringify(
options,
)}`,
);
envVarCollection.prepend(key, value, options);
}
return;
}
traceVerbose(`Setting environment variable ${key} in collection to ${value}`);
envVarCollection.replace(key, value, {
const options = {
applyAtShellIntegration: true,
applyAtProcessCreation: true,
});
};
traceVerbose(
`Setting environment variable ${key} in collection to ${value} ${JSON.stringify(options)}`,
);
envVarCollection.replace(key, value, options);
}
}
});
Expand Down

0 comments on commit 2dc158e

Please sign in to comment.