Skip to content

Commit

Permalink
Log whether shell integration is active (#22346)
Browse files Browse the repository at this point in the history
For #20950
  • Loading branch information
Kartik Raj authored Oct 25, 2023
1 parent bcb1025 commit b46e1a6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
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

0 comments on commit b46e1a6

Please sign in to comment.