From 7fdbde00daf88be162202927d28ab73fc6e86717 Mon Sep 17 00:00:00 2001 From: Karthik Nadig Date: Thu, 6 Nov 2025 11:13:57 -0800 Subject: [PATCH] fix: missing `&` when running PEt command --- src/helpers.ts | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/helpers.ts b/src/helpers.ts index 3a5992fa..7207a46b 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -5,6 +5,9 @@ import { normalizePath } from './common/utils/pathUtils'; import { isWindows } from './common/utils/platformUtils'; import { createTerminal, showInputBoxWithButtons } from './common/window.apis'; import { getConfiguration } from './common/workspace.apis'; +import { ShellConstants } from './features/common/shellConstants'; +import { identifyTerminalShell } from './features/common/shellDetector'; +import { quoteArgs } from './features/execution/execUtils'; import { getAutoActivationType } from './features/terminal/utils'; import { EnvironmentManagers, PythonProjectManager } from './internal.api'; import { getNativePythonToolsPath, NativeEnvInfo, NativePythonFinder } from './managers/common/nativePythonFinder'; @@ -182,7 +185,19 @@ export async function runPetInTerminalImpl(): Promise { terminal.show(); // Run pet find --verbose - terminal.sendText(`"${petPath}" find --verbose`, true); + const shellType = identifyTerminalShell(terminal); + const executable = petPath; + const args = ['find', '--verbose']; + if (terminal.shellIntegration) { + // use shell integration if available + terminal.shellIntegration.executeCommand(executable, args); + } else { + let text = quoteArgs([executable, ...args]).join(' '); + if (shellType === ShellConstants.PWSH && !text.startsWith('&')) { + text = `& ${text}`; + } + terminal.sendText(text, true); + } traceInfo(`Running PET find command: ${petPath} find --verbose`); } else if (selectedOption.label === 'Resolve Environment...') { try { @@ -209,7 +224,18 @@ export async function runPetInTerminalImpl(): Promise { terminal.show(); // Run pet resolve with the provided path - terminal.sendText(`"${petPath}" resolve "${inputPath.trim()}"`, true); + const shellType = identifyTerminalShell(terminal); + const executable = petPath; + const args = ['resolve', inputPath.trim()]; + if (terminal.shellIntegration) { + terminal.shellIntegration.executeCommand(executable, args); + } else { + let text = quoteArgs([executable, ...args]).join(' '); + if (shellType === ShellConstants.PWSH && !text.startsWith('&')) { + text = `& ${text}`; + } + terminal.sendText(text, true); + } traceInfo(`Running PET resolve command: ${petPath} resolve "${inputPath.trim()}"`); } } catch (ex) {