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
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"publisher": "ms-python",
"preview": true,
"engines": {
"vscode": "^1.100.0-20250407"
"vscode": "^1.104.0-20250815"
},
"categories": [
"Other"
Expand Down
4 changes: 4 additions & 0 deletions src/common/window.apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ export function activeTerminal(): Terminal | undefined {
return window.activeTerminal;
}

export function activeTerminalShellIntegration() {
return window.activeTerminal?.shellIntegration;
}

export function activeTextEditor(): TextEditor | undefined {
return window.activeTextEditor;
}
Expand Down
5 changes: 4 additions & 1 deletion src/features/terminal/shellStartupSetupHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ export async function handleSettingUpShellProfile(
callback: (provider: ShellStartupScriptProvider, result: boolean) => void,
): Promise<void> {
const shells = providers.map((p) => p.shellType).join(', ');
// TODO: Get opinions on potentially modifying the prompt
// - If shell integration is active, we won't need to modify user's shell profile, init scripts.
// - Current prompt we have below may not be the most accurate description.
const response = await showInformationMessage(
l10n.t(
'To enable "{0}" activation, your shell profile(s) need to be updated to include the necessary startup scripts. Would you like to proceed with these changes?',
'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?',
ACT_TYPE_SHELL,
),
{ modal: true, detail: l10n.t('Shells: {0}', shells) },
Expand Down
4 changes: 2 additions & 2 deletions src/features/terminal/shells/bash/bashConstants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const BASH_ENV_KEY = 'VSCODE_BASH_ACTIVATE';
export const ZSH_ENV_KEY = 'VSCODE_ZSH_ACTIVATE';
export const BASH_ENV_KEY = 'VSCODE_PYTHON_BASH_ACTIVATE';
export const ZSH_ENV_KEY = 'VSCODE_PYTHON_ZSH_ACTIVATE';
export const BASH_SCRIPT_VERSION = '0.1.1';
4 changes: 4 additions & 0 deletions src/features/terminal/shells/bash/bashStartup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +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 { shellIntegrationForActiveTerminal } from '../common/shellUtils';
import { ShellScriptEditState, ShellSetupState, ShellStartupScriptProvider } from '../startupProvider';
import { BASH_ENV_KEY, BASH_SCRIPT_VERSION, ZSH_ENV_KEY } from './bashConstants';

Expand Down Expand Up @@ -69,6 +70,9 @@ async function isStartupSetup(profile: string, key: string): Promise<ShellSetupS
}

async function setupStartup(profile: string, key: string, name: string): Promise<boolean> {
if (shellIntegrationForActiveTerminal(name, profile)) {
return true;
}
const activationContent = getActivationContent(key);

try {
Expand Down
2 changes: 1 addition & 1 deletion src/features/terminal/shells/cmd/cmdConstants.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const CMD_ENV_KEY = 'VSCODE_CMD_ACTIVATE';
export const CMD_ENV_KEY = 'VSCODE_PYTHON_CMD_ACTIVATE';
export const CMD_SCRIPT_VERSION = '0.1.0';
15 changes: 15 additions & 0 deletions src/features/terminal/shells/common/shellUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { PythonCommandRunConfiguration, PythonEnvironment } from '../../../../api';
import { traceInfo } from '../../../../common/logging';
import { isWindows } from '../../../../common/utils/platformUtils';
import { activeTerminalShellIntegration } from '../../../../common/window.apis';
import { ShellConstants } from '../../../common/shellConstants';
import { quoteArgs } from '../../../execution/execUtils';

Expand Down Expand Up @@ -95,3 +97,16 @@ export function extractProfilePath(content: string): string | undefined {
}
return undefined;
}

export function shellIntegrationForActiveTerminal(name: string, profile: string): boolean {
const hasShellIntegration = activeTerminalShellIntegration();

if (hasShellIntegration) {
traceInfo(
`SHELL: Shell integration is available on your active terminal. Python activate scripts will be evaluated at shell integration level.
Skipping modification of ${name} profile at: ${profile}`,
);
return true;
}
return false;
}
4 changes: 4 additions & 0 deletions src/features/terminal/shells/fish/fishStartup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +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 { shellIntegrationForActiveTerminal } from '../common/shellUtils';
import { ShellScriptEditState, ShellSetupState, ShellStartupScriptProvider } from '../startupProvider';
import { FISH_ENV_KEY, FISH_SCRIPT_VERSION } from './fishConstants';

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

async function setupStartup(profilePath: string, key: string): Promise<boolean> {
try {
if (shellIntegrationForActiveTerminal('fish', profilePath)) {
return true;
}
const activationContent = getActivationContent(key);
await fs.mkdirp(path.dirname(profilePath));

Expand Down
2 changes: 1 addition & 1 deletion src/features/terminal/shells/pwsh/pwshConstants.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const POWERSHELL_ENV_KEY = 'VSCODE_PWSH_ACTIVATE';
export const POWERSHELL_ENV_KEY = 'VSCODE_PYTHON_PWSH_ACTIVATE';
export const PWSH_SCRIPT_VERSION = '0.1.1';
10 changes: 9 additions & 1 deletion src/features/terminal/shells/pwsh/pwshStartup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ import assert from 'assert';
import { getWorkspacePersistentState } from '../../../../common/persistentState';
import { ShellConstants } from '../../../common/shellConstants';
import { hasStartupCode, insertStartupCode, removeStartupCode } from '../common/editUtils';
import { extractProfilePath, PROFILE_TAG_END, PROFILE_TAG_START } from '../common/shellUtils';
import {
extractProfilePath,
PROFILE_TAG_END,
PROFILE_TAG_START,
shellIntegrationForActiveTerminal,
} from '../common/shellUtils';
import { POWERSHELL_ENV_KEY, PWSH_SCRIPT_VERSION } from './pwshConstants';

const PWSH_PROFILE_PATH_CACHE_KEY = 'PWSH_PROFILE_PATH_CACHE';
Expand Down Expand Up @@ -140,6 +145,9 @@ async function isPowerShellStartupSetup(shell: string, profile: string): Promise
}

async function setupPowerShellStartup(shell: string, profile: string): Promise<boolean> {
if (shellIntegrationForActiveTerminal(shell, profile)) {
return true;
}
const activationContent = getActivationContent();

try {
Expand Down
Loading