Skip to content

Commit c6d7168

Browse files
authored
Be less aggressive about removing Python hooks in shell profile (#1070)
Part of #1023 Resolves: #1069 Tests coming: #1019
1 parent 0adb503 commit c6d7168

File tree

4 files changed

+6
-47
lines changed

4 files changed

+6
-47
lines changed

src/features/terminal/shells/bash/bashStartup.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import which from 'which';
55
import { traceError, traceInfo, traceVerbose } from '../../../../common/logging';
66
import { ShellConstants } from '../../../common/shellConstants';
77
import { hasStartupCode, insertStartupCode, removeStartupCode } from '../common/editUtils';
8-
import { getShellIntegrationEnabledCache, isWsl, shellIntegrationForActiveTerminal } from '../common/shellUtils';
98
import { ShellScriptEditState, ShellSetupState, ShellStartupScriptProvider } from '../startupProvider';
109
import { BASH_ENV_KEY, BASH_OLD_ENV_KEY, BASH_SCRIPT_VERSION, ZSH_ENV_KEY, ZSH_OLD_ENV_KEY } from './bashConstants';
1110

@@ -69,11 +68,6 @@ async function isStartupSetup(profile: string, key: string): Promise<ShellSetupS
6968
return ShellSetupState.NotSetup;
7069
}
7170
async function setupStartup(profile: string, key: string, name: string): Promise<boolean> {
72-
const shellIntegrationEnabled = await getShellIntegrationEnabledCache();
73-
if ((shellIntegrationEnabled || (await shellIntegrationForActiveTerminal(name, profile))) && !isWsl()) {
74-
removeStartup(profile, key);
75-
return true;
76-
}
7771
const activationContent = getActivationContent(key);
7872
try {
7973
if (await fs.pathExists(profile)) {

src/features/terminal/shells/fish/fishStartup.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import which from 'which';
66
import { traceError, traceInfo, traceVerbose } from '../../../../common/logging';
77
import { ShellConstants } from '../../../common/shellConstants';
88
import { hasStartupCode, insertStartupCode, removeStartupCode } from '../common/editUtils';
9-
import { getShellIntegrationEnabledCache, isWsl, shellIntegrationForActiveTerminal } from '../common/shellUtils';
109
import { ShellScriptEditState, ShellSetupState, ShellStartupScriptProvider } from '../startupProvider';
1110
import { FISH_ENV_KEY, FISH_OLD_ENV_KEY, FISH_SCRIPT_VERSION } from './fishConstants';
1211

@@ -58,11 +57,6 @@ async function isStartupSetup(profilePath: string, key: string): Promise<boolean
5857

5958
async function setupStartup(profilePath: string, key: string): Promise<boolean> {
6059
try {
61-
const shellIntegrationEnabled = await getShellIntegrationEnabledCache();
62-
if ((shellIntegrationEnabled || (await shellIntegrationForActiveTerminal('fish', profilePath))) && !isWsl()) {
63-
removeFishStartup(profilePath, key);
64-
return true;
65-
}
6660
const activationContent = getActivationContent(key);
6761
await fs.mkdirp(path.dirname(profilePath));
6862

src/features/terminal/shells/pwsh/pwshStartup.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@ import { ShellConstants } from '../../../common/shellConstants';
1313
import { hasStartupCode, insertStartupCode, removeStartupCode } from '../common/editUtils';
1414
import {
1515
extractProfilePath,
16-
getShellIntegrationEnabledCache,
17-
isWsl,
1816
PROFILE_TAG_END,
1917
PROFILE_TAG_START,
20-
shellIntegrationForActiveTerminal,
2118
} from '../common/shellUtils';
2219
import { POWERSHELL_ENV_KEY, POWERSHELL_OLD_ENV_KEY, PWSH_SCRIPT_VERSION } from './pwshConstants';
2320

@@ -169,13 +166,6 @@ async function isPowerShellStartupSetup(shell: string, profile: string): Promise
169166
}
170167

171168
async function setupPowerShellStartup(shell: string, profile: string): Promise<boolean> {
172-
const shellIntegrationEnabled = await getShellIntegrationEnabledCache();
173-
174-
if ((shellIntegrationEnabled || (await shellIntegrationForActiveTerminal(shell, profile))) && !isWsl()) {
175-
removePowerShellStartup(shell, profile, POWERSHELL_OLD_ENV_KEY);
176-
removePowerShellStartup(shell, profile, POWERSHELL_ENV_KEY);
177-
return true;
178-
}
179169
const activationContent = getActivationContent();
180170

181171
try {

src/features/terminal/terminalManager.ts

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -142,20 +142,6 @@ export class TerminalManagerImpl implements TerminalManager {
142142
this.shellSetup.clear();
143143
}
144144
}
145-
if (e.affectsConfiguration('terminal.integrated.shellIntegration.enabled')) {
146-
traceInfo('Shell integration setting changed, invalidating cache');
147-
const updatedShellIntegrationSetting = await getShellIntegrationEnabledCache();
148-
if (!updatedShellIntegrationSetting) {
149-
const shells = new Set(
150-
terminals()
151-
.map((t) => identifyTerminalShell(t))
152-
.filter((t) => t !== 'unknown'),
153-
);
154-
if (shells.size > 0) {
155-
await this.handleSetupCheck(shells);
156-
}
157-
}
158-
}
159145
}),
160146
onDidChangeWindowState((e) => {
161147
this.hasFocus = e.focused;
@@ -185,27 +171,22 @@ export class TerminalManagerImpl implements TerminalManager {
185171
);
186172

187173
if (shellIntegrationLikelyAvailable && !shouldUseProfileActivation(p.shellType)) {
188-
// Shell integration available and NOT in WSL - skip setup
189-
await p.teardownScripts();
174+
// Shell integration available and NOT in WSL - skip setup.
175+
// NOTE: We intentionally do NOT teardown scripts here. If the user stays in
176+
// shellStartup mode, be less aggressive about clearing profile modifications.
190177
this.shellSetup.set(p.shellType, true);
191178
traceVerbose(
192-
`Shell integration available for ${p.shellType} (not WSL), skipping prompt, and profile modification.`,
179+
`Shell integration likely available. Skipping setup of shell profile for ${p.shellType}.`,
193180
);
194181
} else {
195-
// WSL (regardless of integration) OR no shell integration - needs setup
182+
// WSL (regardless of integration) OR no/disabled shell integration - needs setup
196183
this.shellSetup.set(p.shellType, false);
197184
shellsToSetup.push(p);
198185
traceVerbose(
199-
`Shell integration is NOT available. Shell profile for ${p.shellType} is not setup.`,
186+
`Shell integration is NOT available or disabled. Shell profile for ${p.shellType} is not setup.`,
200187
);
201188
}
202189
} else if (state === ShellSetupState.Setup) {
203-
if (shellIntegrationLikelyAvailable && !shouldUseProfileActivation(p.shellType)) {
204-
await p.teardownScripts();
205-
traceVerbose(
206-
`Shell integration available for ${p.shellType}, removed profile script in favor of shell integration.`,
207-
);
208-
}
209190
this.shellSetup.set(p.shellType, true);
210191
traceVerbose(`Shell profile for ${p.shellType} is setup.`);
211192
} else if (state === ShellSetupState.NotInstalled) {

0 commit comments

Comments
 (0)