Skip to content

Commit 66bc570

Browse files
authored
Fix to prevent multiple shell startup prompts (#738)
Resolves: microsoft/vscode#262213
1 parent 7b3348a commit 66bc570

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

src/features/terminal/shellStartupSetupHandlers.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ export async function handleSettingUpShellProfile(
1111
callback: (provider: ShellStartupScriptProvider, result: boolean) => void,
1212
): Promise<void> {
1313
const shells = providers.map((p) => p.shellType).join(', ');
14-
// TODO: Get opinions on potentially modifying the prompt
15-
// - If shell integration is active, we won't need to modify user's shell profile, init scripts.
16-
// - Current prompt we have below may not be the most accurate description.
14+
// Only show prompt when shell integration is not available, or disabled.
1715
const response = await showInformationMessage(
1816
l10n.t(
1917
'To enable "{0}" activation, your shell profile(s) may need to be updated to include the necessary startup scripts. Would you like to proceed with these changes?',

src/features/terminal/shells/common/shellUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export function extractProfilePath(content: string): string | undefined {
9898
return undefined;
9999
}
100100

101-
export function shellIntegrationForActiveTerminal(name: string, profile: string): boolean {
101+
export function shellIntegrationForActiveTerminal(name: string, profile?: string): boolean {
102102
const hasShellIntegration = activeTerminalShellIntegration();
103103

104104
if (hasShellIntegration) {

src/features/terminal/terminalManager.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { getConfiguration, onDidChangeConfiguration } from '../../common/workspa
1616
import { isActivatableEnvironment } from '../common/activation';
1717
import { identifyTerminalShell } from '../common/shellDetector';
1818
import { getPythonApi } from '../pythonApi';
19+
import { shellIntegrationForActiveTerminal } from './shells/common/shellUtils';
1920
import { ShellEnvsProvider, ShellSetupState, ShellStartupScriptProvider } from './shells/startupProvider';
2021
import { handleSettingUpShellProfile } from './shellStartupSetupHandlers';
2122
import {
@@ -153,9 +154,20 @@ export class TerminalManagerImpl implements TerminalManager {
153154
traceVerbose(`Checking shell profile for ${p.shellType}.`);
154155
const state = await p.isSetup();
155156
if (state === ShellSetupState.NotSetup) {
156-
this.shellSetup.set(p.shellType, false);
157-
shellsToSetup.push(p);
158-
traceVerbose(`Shell profile for ${p.shellType} is not setup.`);
157+
// Check if shell integration is available before marking for setup
158+
if (shellIntegrationForActiveTerminal(p.name)) {
159+
this.shellSetup.set(p.shellType, true);
160+
traceVerbose(
161+
`Shell integration available for ${p.shellType}, skipping prompt, and profile modification.`,
162+
);
163+
} else {
164+
// No shell integration, mark for setup
165+
this.shellSetup.set(p.shellType, false);
166+
shellsToSetup.push(p);
167+
traceVerbose(
168+
`Shell integration is NOT avaoiable. Shell profile for ${p.shellType} is not setup.`,
169+
);
170+
}
159171
} else if (state === ShellSetupState.Setup) {
160172
this.shellSetup.set(p.shellType, true);
161173
traceVerbose(`Shell profile for ${p.shellType} is setup.`);

0 commit comments

Comments
 (0)