Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log whether shell integration is active #22346

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/client/terminals/envCollectionActivation/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ export class TerminalEnvVarCollectionService implements IExtensionActivationServ
this,
this.disposables,
);
const isActive = this.isShellIntegrationActive();
if (!isActive) {
traceWarn(`Shell integration is not active, environment activated maybe overriden by the shell.`);
}
this.registeredOnce = true;
}
this._applyCollection(resource).ignoreErrors();
Expand Down Expand Up @@ -153,13 +157,14 @@ export class TerminalEnvVarCollectionService implements IExtensionActivationServ
shell,
);
const env = activatedEnv ? normCaseKeys(activatedEnv) : undefined;
traceVerbose(`Activated environment variables for ${resource?.fsPath}`, env);
if (!env) {
const shellType = identifyShellFromShellPath(shell);
const defaultShell = defaultShells[this.platform.osType];
if (defaultShell?.shellType !== shellType) {
// Commands to fetch env vars may fail in custom shells due to unknown reasons, in that case
// fallback to default shells as they are known to work better.
await this._applyCollection(resource, defaultShell?.shell);
await this._applyCollectionImpl(resource, defaultShell?.shell);
return;
}
await this.trackTerminalPrompt(shell, resource, env);
Expand Down Expand Up @@ -352,6 +357,9 @@ export class TerminalEnvVarCollectionService implements IExtensionActivationServ
// https://code.visualstudio.com/docs/terminal/shell-integration#_automatic-script-injection
return true;
}
if (isEnabled) {
traceVerbose('Shell integrated is disabled in user settings.');
}
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { TerminalShellType } from '../../common/terminal/types';
* https://code.visualstudio.com/docs/terminal/shell-integration
*/
export const ShellIntegrationShells = [
TerminalShellType.commandPrompt, // Shell integration is not supported, but is also not needed to activate the env.
TerminalShellType.powershell,
TerminalShellType.powershellCore,
TerminalShellType.bash,
Expand Down
Loading