Skip to content
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: 4 additions & 6 deletions src/features/terminal/shells/bash/bashStartup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,12 @@ function getActivationContent(key: string): string {
async function isStartupSetup(profile: string, key: string): Promise<ShellSetupState> {
if (await fs.pathExists(profile)) {
const content = await fs.readFile(profile, 'utf8');
return hasStartupCode(content, regionStart, regionEnd, [key])
? ShellSetupState.Setup
: ShellSetupState.NotSetup;
} else {
return ShellSetupState.NotSetup;
if (hasStartupCode(content, regionStart, regionEnd, [key])) {
return ShellSetupState.Setup;
}
}
return ShellSetupState.NotSetup;
}

async function setupStartup(profile: string, key: string, name: string): Promise<boolean> {
if (shellIntegrationForActiveTerminal(name, profile)) {
removeStartup(profile, key);
Expand Down
23 changes: 19 additions & 4 deletions src/features/terminal/terminalManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,23 @@ export class TerminalManagerImpl implements TerminalManager {
const shellsToSetup: ShellStartupScriptProvider[] = [];
await Promise.all(
providers.map(async (p) => {
const state = await p.isSetup();
if (this.shellSetup.has(p.shellType)) {
traceVerbose(`Shell profile for ${p.shellType} already checked.`);
return;
// This ensures modified scripts are detected even after initial setup
const cachedSetup = this.shellSetup.get(p.shellType);
if ((state === ShellSetupState.Setup) !== cachedSetup) {
traceVerbose(`Shell profile for ${p.shellType} state changed, updating cache.`);
// State changed - clear cache and re-evaluate
this.shellSetup.delete(p.shellType);
} else {
traceVerbose(`Shell profile for ${p.shellType} already checked.`);
return;
}
}
traceVerbose(`Checking shell profile for ${p.shellType}.`);
const state = await p.isSetup();
if (state === ShellSetupState.NotSetup) {
// Check if shell integration is available before marking for setup
if (shellIntegrationForActiveTerminal(p.name)) {
await p.teardownScripts();
this.shellSetup.set(p.shellType, true);
traceVerbose(
`Shell integration available for ${p.shellType}, skipping prompt, and profile modification.`,
Expand All @@ -169,6 +177,12 @@ export class TerminalManagerImpl implements TerminalManager {
);
}
} else if (state === ShellSetupState.Setup) {
if (shellIntegrationForActiveTerminal(p.name)) {
await p.teardownScripts();
traceVerbose(
`Shell integration available for ${p.shellType}, removed profile script in favor of shell integration.`,
);
}
this.shellSetup.set(p.shellType, true);
traceVerbose(`Shell profile for ${p.shellType} is setup.`);
} else if (state === ShellSetupState.NotInstalled) {
Expand Down Expand Up @@ -228,6 +242,7 @@ export class TerminalManagerImpl implements TerminalManager {
let actType = getAutoActivationType();
const shellType = identifyTerminalShell(terminal);
if (actType === ACT_TYPE_SHELL) {
await this.handleSetupCheck(shellType);
actType = await this.getEffectiveActivationType(shellType);
}

Expand Down
Loading