Skip to content
Closed
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
4 changes: 2 additions & 2 deletions src/features/terminal/shells/bash/bashStartup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import which from 'which';
import { traceError, traceInfo, traceVerbose } from '../../../../common/logging';
import { ShellConstants } from '../../../common/shellConstants';
import { hasStartupCode, insertStartupCode, removeStartupCode } from '../common/editUtils';
import { getShellIntegrationEnabledCache, isWsl, shellIntegrationForActiveTerminal } from '../common/shellUtils';
import { getShellIntegrationEnabledSetting, isWsl, shellIntegrationForActiveTerminal } from '../common/shellUtils';
import { ShellScriptEditState, ShellSetupState, ShellStartupScriptProvider } from '../startupProvider';
import { BASH_ENV_KEY, BASH_OLD_ENV_KEY, BASH_SCRIPT_VERSION, ZSH_ENV_KEY, ZSH_OLD_ENV_KEY } from './bashConstants';

Expand Down Expand Up @@ -69,7 +69,7 @@ async function isStartupSetup(profile: string, key: string): Promise<ShellSetupS
return ShellSetupState.NotSetup;
}
async function setupStartup(profile: string, key: string, name: string): Promise<boolean> {
const shellIntegrationEnabled = await getShellIntegrationEnabledCache();
const shellIntegrationEnabled = await getShellIntegrationEnabledSetting();
if ((shellIntegrationEnabled || (await shellIntegrationForActiveTerminal(name, profile))) && !isWsl()) {
removeStartup(profile, key);
return true;
Expand Down
11 changes: 1 addition & 10 deletions src/features/terminal/shells/common/shellUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { PythonCommandRunConfiguration, PythonEnvironment } from '../../../../api';
import { traceInfo } from '../../../../common/logging';
import { getGlobalPersistentState } from '../../../../common/persistentState';
import { timeout } from '../../../../common/utils/asyncUtils';
import { isWindows } from '../../../../common/utils/platformUtils';
import { activeTerminalShellIntegration } from '../../../../common/window.apis';
Expand All @@ -9,8 +8,6 @@ import { ShellConstants } from '../../../common/shellConstants';
import { quoteArgs } from '../../../execution/execUtils';
import { SHELL_INTEGRATION_POLL_INTERVAL, SHELL_INTEGRATION_TIMEOUT } from '../../utils';

export const SHELL_INTEGRATION_STATE_KEY = 'shellIntegration.enabled';

function getCommandAsString(command: PythonCommandRunConfiguration[], shell: string, delimiter: string): string {
const parts = [];
for (const cmd of command) {
Expand Down Expand Up @@ -119,10 +116,6 @@ export async function shellIntegrationForActiveTerminal(name: string, profile?:
`SHELL: Shell integration is available on your active terminal, with name ${name} and profile ${profile}. Python activate scripts will be evaluated at shell integration level, except in WSL.`,
);

// Update persistent storage to reflect that shell integration is available
const persistentState = await getGlobalPersistentState();
await persistentState.set(SHELL_INTEGRATION_STATE_KEY, true);

return true;
}
return false;
Expand All @@ -133,8 +126,7 @@ export function isWsl(): boolean {
return !!(process.env.WSL_DISTRO_NAME || process.env.WSL_INTEROP || process.env.WSLENV);
}

export async function getShellIntegrationEnabledCache(): Promise<boolean> {
const persistentState = await getGlobalPersistentState();
export async function getShellIntegrationEnabledSetting(): Promise<boolean> {
const shellIntegrationInspect =
getConfiguration('terminal.integrated').inspect<boolean>('shellIntegration.enabled');

Expand All @@ -158,7 +150,6 @@ export async function getShellIntegrationEnabledCache(): Promise<boolean> {
}
}

await persistentState.set(SHELL_INTEGRATION_STATE_KEY, shellIntegrationEnabled);
return shellIntegrationEnabled;
}

Expand Down
4 changes: 2 additions & 2 deletions src/features/terminal/shells/fish/fishStartup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import which from 'which';
import { traceError, traceInfo, traceVerbose } from '../../../../common/logging';
import { ShellConstants } from '../../../common/shellConstants';
import { hasStartupCode, insertStartupCode, removeStartupCode } from '../common/editUtils';
import { getShellIntegrationEnabledCache, isWsl, shellIntegrationForActiveTerminal } from '../common/shellUtils';
import { getShellIntegrationEnabledSetting, isWsl, shellIntegrationForActiveTerminal } from '../common/shellUtils';
import { ShellScriptEditState, ShellSetupState, ShellStartupScriptProvider } from '../startupProvider';
import { FISH_ENV_KEY, FISH_OLD_ENV_KEY, FISH_SCRIPT_VERSION } from './fishConstants';

Expand Down Expand Up @@ -58,7 +58,7 @@ async function isStartupSetup(profilePath: string, key: string): Promise<boolean

async function setupStartup(profilePath: string, key: string): Promise<boolean> {
try {
const shellIntegrationEnabled = await getShellIntegrationEnabledCache();
const shellIntegrationEnabled = await getShellIntegrationEnabledSetting();
if ((shellIntegrationEnabled || (await shellIntegrationForActiveTerminal('fish', profilePath))) && !isWsl()) {
removeFishStartup(profilePath, key);
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/features/terminal/shells/pwsh/pwshStartup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { ShellConstants } from '../../../common/shellConstants';
import { hasStartupCode, insertStartupCode, removeStartupCode } from '../common/editUtils';
import {
extractProfilePath,
getShellIntegrationEnabledCache,
getShellIntegrationEnabledSetting,
isWsl,
PROFILE_TAG_END,
PROFILE_TAG_START,
Expand Down Expand Up @@ -169,7 +169,7 @@ async function isPowerShellStartupSetup(shell: string, profile: string): Promise
}

async function setupPowerShellStartup(shell: string, profile: string): Promise<boolean> {
const shellIntegrationEnabled = await getShellIntegrationEnabledCache();
const shellIntegrationEnabled = await getShellIntegrationEnabledSetting();

if ((shellIntegrationEnabled || (await shellIntegrationForActiveTerminal(shell, profile))) && !isWsl()) {
removePowerShellStartup(shell, profile, POWERSHELL_OLD_ENV_KEY);
Expand Down
6 changes: 3 additions & 3 deletions src/features/terminal/terminalManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { isActivatableEnvironment } from '../common/activation';
import { identifyTerminalShell } from '../common/shellDetector';
import { getPythonApi } from '../pythonApi';
import {
getShellIntegrationEnabledCache,
getShellIntegrationEnabledSetting,
isWsl,
shellIntegrationForActiveTerminal,
shouldUseProfileActivation,
Expand Down Expand Up @@ -144,7 +144,7 @@ export class TerminalManagerImpl implements TerminalManager {
}
if (e.affectsConfiguration('terminal.integrated.shellIntegration.enabled')) {
traceInfo('Shell integration setting changed, invalidating cache');
const updatedShellIntegrationSetting = await getShellIntegrationEnabledCache();
const updatedShellIntegrationSetting = await getShellIntegrationEnabledSetting();
if (!updatedShellIntegrationSetting) {
const shells = new Set(
terminals()
Expand All @@ -171,7 +171,7 @@ export class TerminalManagerImpl implements TerminalManager {
await Promise.all(
providers.map(async (p) => {
const state = await p.isSetup();
const shellIntegrationEnabledSetting = await getShellIntegrationEnabledCache();
const shellIntegrationEnabledSetting = await getShellIntegrationEnabledSetting();
const shellIntegrationActiveTerminal = await shellIntegrationForActiveTerminal(p.name);
const shellIntegrationLikelyAvailable =
shellIntegrationEnabledSetting || shellIntegrationActiveTerminal;
Expand Down