@@ -19,6 +19,7 @@ import {
19
19
} from './common/window.apis' ;
20
20
import { getConfiguration } from './common/workspace.apis' ;
21
21
import { createManagerReady } from './features/common/managerReady' ;
22
+ import { identifyTerminalShell } from './features/common/shellDetector' ;
22
23
import { AutoFindProjects } from './features/creators/autoFindProjects' ;
23
24
import { ExistingProjects } from './features/creators/existingProjects' ;
24
25
import { NewPackageProject } from './features/creators/newPackageProject' ;
@@ -49,7 +50,7 @@ import { PythonProjectManagerImpl } from './features/projectManager';
49
50
import { getPythonApi , setPythonApi } from './features/pythonApi' ;
50
51
import { registerCompletionProvider } from './features/settings/settingCompletions' ;
51
52
import { setActivateMenuButtonContext } from './features/terminal/activateMenuButton' ;
52
- import { normalizeShellPath } from './features/terminal/shells/common/shellUtils' ;
53
+ import { getShellCommandAsString , normalizeShellPath } from './features/terminal/shells/common/shellUtils' ;
53
54
import {
54
55
clearShellProfileCache ,
55
56
createShellEnvProviders ,
@@ -435,6 +436,7 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
435
436
commands . registerCommand ( 'python-envs.runPetInTerminal' , async ( ) => {
436
437
try {
437
438
const petPath = await getNativePythonToolsPath ( ) ;
439
+ let command : { subcommand : string ; args ?: string [ ] } | undefined ;
438
440
439
441
// Show quick pick menu for PET operation selection
440
442
const selectedOption = await window . showQuickPick (
@@ -467,8 +469,7 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
467
469
468
470
if ( selectedOption . label === 'Find All Environments' ) {
469
471
// Run pet find --verbose
470
- terminal . sendText ( `"${ petPath } " find --verbose` , true ) ;
471
- traceInfo ( `Running PET find command: ${ petPath } find --verbose` ) ;
472
+ command = { subcommand : 'find' , args : [ '--verbose' ] } ;
472
473
} else if ( selectedOption . label === 'Resolve Environment...' ) {
473
474
// Show input box for path
474
475
const placeholder = isWindows ( ) ? 'C:\\path\\to\\python\\executable' : '/path/to/python/executable' ;
@@ -489,8 +490,15 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
489
490
}
490
491
491
492
// Run pet resolve with the provided path
492
- terminal . sendText ( `"${ petPath } " resolve "${ inputPath . trim ( ) } "` , true ) ;
493
- traceInfo ( `Running PET resolve command: ${ petPath } resolve "${ inputPath . trim ( ) } "` ) ;
493
+ command = { subcommand : 'resolve' , args : [ inputPath . trim ( ) ] } ;
494
+ }
495
+
496
+ if ( command ) {
497
+ const execString = getShellCommandAsString ( identifyTerminalShell ( terminal ) , [
498
+ { executable : petPath , args : [ command . subcommand , ...( command . args || [ ] ) ] } ,
499
+ ] ) ;
500
+ terminal . sendText ( execString , true ) ;
501
+ traceInfo ( `Running PET ${ command . subcommand } command: ${ execString } ` ) ;
494
502
}
495
503
} catch ( error ) {
496
504
traceError ( 'Error running PET in terminal' , error ) ;
0 commit comments