Skip to content

Commit 04020d1

Browse files
committed
chore: merge with main + API changes from main
1 parent 4006afe commit 04020d1

8 files changed

Lines changed: 47 additions & 24 deletions

File tree

src/extension.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ import { registerTools } from './common/lm.apis';
5757
import { GetPackagesTool } from './features/copilotTools';
5858
import { TerminalActivationImpl } from './features/terminal/terminalActivationState';
5959
import { getEnvironmentForTerminal, normalizeShellPath } from './features/terminal/utils';
60-
import { PowerShellStartupProvider } from './features/terminal/startup/powershellStartup';
60+
import { PwshStartupProvider } from './features/terminal/startup/powershellStartup';
6161
import { ShellStartupActivationManagerImpl } from './features/terminal/startup/activateUsingShellStartup';
6262
import {
6363
BashStartupProvider,
@@ -66,6 +66,8 @@ import {
6666
} from './features/terminal/startup/bashStartup';
6767
import { FishStartupProvider } from './features/terminal/startup/fishStartup';
6868
import { isWindows } from './common/utils/platformUtils';
69+
import { CmdStartupProvider } from './features/terminal/startup/cmdStartup';
70+
import { NuShellStartupProvider } from './features/terminal/startup/nuShellStartup';
6971

7072
export async function activate(context: ExtensionContext): Promise<PythonEnvironmentApi> {
7173
const start = new StopWatch();
@@ -93,12 +95,13 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
9395

9496
const terminalActivation = new TerminalActivationImpl();
9597
const shellStartupProviders = isWindows()
96-
? [new PowerShellStartupProvider(), new GitBashStartupProvider()]
98+
? [new PwshStartupProvider(), new GitBashStartupProvider(), new CmdStartupProvider()]
9799
: [
98-
new PowerShellStartupProvider(),
100+
new PwshStartupProvider(),
99101
new BashStartupProvider(),
100102
new ZshStartupProvider(),
101103
new FishStartupProvider(),
104+
new NuShellStartupProvider(),
102105
];
103106
const shellStartupActivationManager = new ShellStartupActivationManagerImpl(
104107
context.environmentVariableCollection,

src/features/common/activation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function getActivationCommand(
2020

2121
export function getActivationCommandForShell(
2222
environment: PythonEnvironment,
23-
shell: TerminalShellType,
23+
shell: string,
2424
): PythonCommandRunConfiguration[] | undefined {
2525
let activation: PythonCommandRunConfiguration[] | undefined;
2626
if (environment.execInfo?.shellActivation) {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export namespace ShellConstants {
2+
export const PWSH = 'pwsh';
3+
export const BASH = 'bash';
4+
export const ZSH = 'zsh';
5+
export const FISH = 'fish';
6+
export const CMD = 'cmd';
7+
export const SH = 'sh';
8+
export const NU = 'nu';
9+
export const GITBASH = 'gitbash';
10+
export const WSL = 'wsl';
11+
export const CSH = 'csh';
12+
export const TCSH = 'tcsh';
13+
export const KSH = 'ksh';
14+
export const XONSH = 'xonsh';
15+
}

src/features/terminal/startup/bashStartup.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import * as path from 'path';
33
import * as os from 'os';
44
import { ShellScriptEditState, ShellSetupState, ShellStartupProvider } from './startupProvider';
55
import { EnvironmentVariableCollection } from 'vscode';
6-
import { PythonCommandRunConfiguration, PythonEnvironment, TerminalShellType } from '../../../api';
6+
import { PythonCommandRunConfiguration, PythonEnvironment } from '../../../api';
77
import { getActivationCommandForShell } from '../../common/activation';
88
import { quoteArgs } from '../../execution/execUtils';
99
import { traceError, traceInfo, traceVerbose } from '../../../common/logging';
1010
import which from 'which';
11+
import { ShellConstants } from '../../common/shellConstants';
1112

1213
async function isBashLikeInstalled(): Promise<boolean> {
1314
const result = await Promise.all([which('bash', { nothrow: true }), which('sh', { nothrow: true })]);
@@ -245,7 +246,7 @@ export class BashStartupProvider implements ShellStartupProvider {
245246

246247
async updateEnvVariables(collection: EnvironmentVariableCollection, env: PythonEnvironment): Promise<void> {
247248
try {
248-
const bashActivation = getActivationCommandForShell(env, TerminalShellType.bash);
249+
const bashActivation = getActivationCommandForShell(env, ShellConstants.BASH);
249250
if (bashActivation) {
250251
const command = getCommandAsString(bashActivation);
251252
collection.replace(this.bashActivationEnvVarKey, command);
@@ -268,7 +269,7 @@ export class BashStartupProvider implements ShellStartupProvider {
268269
}
269270

270271
try {
271-
const bashActivation = getActivationCommandForShell(env, TerminalShellType.bash);
272+
const bashActivation = getActivationCommandForShell(env, ShellConstants.BASH);
272273
return bashActivation
273274
? new Map([[this.bashActivationEnvVarKey, getCommandAsString(bashActivation)]])
274275
: undefined;
@@ -338,7 +339,7 @@ export class ZshStartupProvider implements ShellStartupProvider {
338339

339340
async updateEnvVariables(envVars: EnvironmentVariableCollection, env: PythonEnvironment): Promise<void> {
340341
try {
341-
const zshActivation = getActivationCommandForShell(env, TerminalShellType.zsh);
342+
const zshActivation = getActivationCommandForShell(env, ShellConstants.ZSH);
342343
if (zshActivation) {
343344
const command = getCommandAsString(zshActivation);
344345
envVars.replace(this.zshActivationEnvVarKey, command);
@@ -361,7 +362,7 @@ export class ZshStartupProvider implements ShellStartupProvider {
361362
}
362363

363364
try {
364-
const zshActivation = getActivationCommandForShell(env, TerminalShellType.zsh);
365+
const zshActivation = getActivationCommandForShell(env, ShellConstants.ZSH);
365366
return zshActivation
366367
? new Map([[this.zshActivationEnvVarKey, getCommandAsString(zshActivation)]])
367368
: undefined;
@@ -429,7 +430,7 @@ export class GitBashStartupProvider implements ShellStartupProvider {
429430
}
430431
async updateEnvVariables(envVars: EnvironmentVariableCollection, env: PythonEnvironment): Promise<void> {
431432
try {
432-
const bashActivation = getActivationCommandForShell(env, TerminalShellType.gitbash);
433+
const bashActivation = getActivationCommandForShell(env, ShellConstants.GITBASH);
433434
if (bashActivation) {
434435
const command = getCommandAsString(bashActivation);
435436
envVars.replace(this.gitBashActivationEnvVarKey, command);
@@ -450,7 +451,7 @@ export class GitBashStartupProvider implements ShellStartupProvider {
450451
}
451452

452453
try {
453-
const zshActivation = getActivationCommandForShell(env, TerminalShellType.zsh);
454+
const zshActivation = getActivationCommandForShell(env, ShellConstants.GITBASH);
454455
return zshActivation
455456
? new Map([[this.gitBashActivationEnvVarKey, getCommandAsString(zshActivation)]])
456457
: undefined;

src/features/terminal/startup/cmdStartup.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ import * as os from 'os';
44
import { isWindows } from '../../../common/utils/platformUtils';
55
import { ShellScriptEditState, ShellSetupState, ShellStartupProvider } from './startupProvider';
66
import { EnvironmentVariableCollection } from 'vscode';
7-
import { PythonEnvironment, TerminalShellType } from '../../../api';
7+
import { PythonEnvironment } from '../../../api';
88
import { getActivationCommandForShell } from '../../common/activation';
99
import { traceError, traceInfo, traceVerbose } from '../../../common/logging';
1010
import { getCommandAsString } from './utils';
1111
import which from 'which';
1212
import * as cp from 'child_process';
1313
import { promisify } from 'util';
14+
import { ShellConstants } from '../../common/shellConstants';
1415

1516
const exec = promisify(cp.exec);
1617

@@ -276,7 +277,7 @@ export class CmdStartupProvider implements ShellStartupProvider {
276277

277278
async updateEnvVariables(collection: EnvironmentVariableCollection, env: PythonEnvironment): Promise<void> {
278279
try {
279-
const cmdActivation = getActivationCommandForShell(env, TerminalShellType.commandPrompt);
280+
const cmdActivation = getActivationCommandForShell(env, ShellConstants.CMD);
280281
if (cmdActivation) {
281282
const command = getCommandAsString(cmdActivation, '&');
282283
collection.replace(this.cmdActivationEnvVarKey, command);
@@ -299,7 +300,7 @@ export class CmdStartupProvider implements ShellStartupProvider {
299300
}
300301

301302
try {
302-
const cmdActivation = getActivationCommandForShell(env, TerminalShellType.commandPrompt);
303+
const cmdActivation = getActivationCommandForShell(env, ShellConstants.CMD);
303304
return cmdActivation
304305
? new Map([[this.cmdActivationEnvVarKey, getCommandAsString(cmdActivation, '&')]])
305306
: undefined;

src/features/terminal/startup/fishStartup.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import * as path from 'path';
33
import * as os from 'os';
44
import { ShellScriptEditState, ShellSetupState, ShellStartupProvider } from './startupProvider';
55
import { EnvironmentVariableCollection } from 'vscode';
6-
import { PythonCommandRunConfiguration, PythonEnvironment, TerminalShellType } from '../../../api';
6+
import { PythonCommandRunConfiguration, PythonEnvironment } from '../../../api';
77
import { getActivationCommandForShell } from '../../common/activation';
88
import { quoteArgs } from '../../execution/execUtils';
99
import { traceError, traceInfo, traceVerbose } from '../../../common/logging';
1010
import which from 'which';
11+
import { ShellConstants } from '../../common/shellConstants';
1112

1213
async function isFishInstalled(): Promise<boolean> {
1314
try {
@@ -161,7 +162,7 @@ export class FishStartupProvider implements ShellStartupProvider {
161162

162163
async updateEnvVariables(collection: EnvironmentVariableCollection, env: PythonEnvironment): Promise<void> {
163164
try {
164-
const fishActivation = getActivationCommandForShell(env, TerminalShellType.fish);
165+
const fishActivation = getActivationCommandForShell(env, ShellConstants.FISH);
165166
if (fishActivation) {
166167
const command = getCommandAsString(fishActivation);
167168
collection.replace(this.fishActivationEnvVarKey, command);
@@ -184,7 +185,7 @@ export class FishStartupProvider implements ShellStartupProvider {
184185
}
185186

186187
try {
187-
const fishActivation = getActivationCommandForShell(env, TerminalShellType.fish);
188+
const fishActivation = getActivationCommandForShell(env, ShellConstants.FISH);
188189
return fishActivation
189190
? new Map([[this.fishActivationEnvVarKey, getCommandAsString(fishActivation)]])
190191
: undefined;

src/features/terminal/startup/nuShellStartup.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import * as path from 'path';
33
import * as os from 'os';
44
import { ShellScriptEditState, ShellSetupState, ShellStartupProvider } from './startupProvider';
55
import { EnvironmentVariableCollection } from 'vscode';
6-
import { PythonCommandRunConfiguration, PythonEnvironment, TerminalShellType } from '../../../api';
6+
import { PythonCommandRunConfiguration, PythonEnvironment } from '../../../api';
77
import { getActivationCommandForShell } from '../../common/activation';
88
import { quoteArgs } from '../../execution/execUtils';
99
import { traceError, traceInfo, traceVerbose } from '../../../common/logging';
1010
import which from 'which';
11+
import { ShellConstants } from '../../common/shellConstants';
1112

1213
async function isNuShellInstalled(): Promise<boolean> {
1314
try {
@@ -171,7 +172,7 @@ export class NuShellStartupProvider implements ShellStartupProvider {
171172

172173
async updateEnvVariables(collection: EnvironmentVariableCollection, env: PythonEnvironment): Promise<void> {
173174
try {
174-
const nuShellActivation = getActivationCommandForShell(env, TerminalShellType.nushell);
175+
const nuShellActivation = getActivationCommandForShell(env, ShellConstants.NU);
175176
if (nuShellActivation) {
176177
const command = getCommandAsString(nuShellActivation);
177178
collection.replace(this.nuShellActivationEnvVarKey, command);
@@ -194,7 +195,7 @@ export class NuShellStartupProvider implements ShellStartupProvider {
194195
}
195196

196197
try {
197-
const nuShellActivation = getActivationCommandForShell(env, TerminalShellType.nushell);
198+
const nuShellActivation = getActivationCommandForShell(env, ShellConstants.NU);
198199
return nuShellActivation
199200
? new Map([[this.nuShellActivationEnvVarKey, getCommandAsString(nuShellActivation)]])
200201
: undefined;

src/features/terminal/startup/powershellStartup.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import * as path from 'path';
33
import { isWindows } from '../../../common/utils/platformUtils';
44
import { ShellScriptEditState, ShellSetupState, ShellStartupProvider } from './startupProvider';
55
import { EnvironmentVariableCollection } from 'vscode';
6-
import { PythonEnvironment, TerminalShellType } from '../../../api';
6+
import { PythonEnvironment } from '../../../api';
77
import { getActivationCommandForShell } from '../../common/activation';
88
import { traceError, traceInfo, traceVerbose } from '../../../common/logging';
99
import { getCommandAsString, runCommand } from './utils';
1010
import which from 'which';
11+
import { ShellConstants } from '../../common/shellConstants';
1112

1213
async function isPowerShellInstalled(): Promise<boolean> {
1314
const result = await Promise.all([which('powershell', { nothrow: true }), which('pwsh', { nothrow: true })]);
@@ -141,7 +142,7 @@ async function removePowerShellStartup(key: string): Promise<boolean> {
141142
return profiles.length > 0 && successfulRemovals === profiles.length;
142143
}
143144

144-
export class PowerShellStartupProvider implements ShellStartupProvider {
145+
export class PwshStartupProvider implements ShellStartupProvider {
145146
public readonly name: string = 'PowerShell';
146147
private readonly pwshActivationEnvVarKey = 'VSCODE_PWSH_ACTIVATE';
147148

@@ -195,7 +196,7 @@ export class PowerShellStartupProvider implements ShellStartupProvider {
195196

196197
async updateEnvVariables(collection: EnvironmentVariableCollection, env: PythonEnvironment): Promise<void> {
197198
try {
198-
const pwshActivation = getActivationCommandForShell(env, TerminalShellType.powershell);
199+
const pwshActivation = getActivationCommandForShell(env, ShellConstants.PWSH);
199200
if (pwshActivation) {
200201
const command = getCommandAsString(pwshActivation, '&&');
201202
collection.replace(this.pwshActivationEnvVarKey, command);
@@ -218,7 +219,7 @@ export class PowerShellStartupProvider implements ShellStartupProvider {
218219
}
219220

220221
try {
221-
const pwshActivation = getActivationCommandForShell(env, TerminalShellType.powershell);
222+
const pwshActivation = getActivationCommandForShell(env, ShellConstants.PWSH);
222223
return pwshActivation
223224
? new Map([[this.pwshActivationEnvVarKey, getCommandAsString(pwshActivation, '&&')]])
224225
: undefined;

0 commit comments

Comments
 (0)