diff --git a/src/features/execution/execUtils.ts b/src/features/execution/execUtils.ts index 9cdfb674..7c61975b 100644 --- a/src/features/execution/execUtils.ts +++ b/src/features/execution/execUtils.ts @@ -1,4 +1,4 @@ -function quoteArg(arg: string): string { +export function quoteArg(arg: string): string { if (arg.indexOf(' ') >= 0 && !(arg.startsWith('"') && arg.endsWith('"'))) { return `"${arg}"`; } diff --git a/src/features/execution/runAsTask.ts b/src/features/execution/runAsTask.ts index 705c0338..9cd77d87 100644 --- a/src/features/execution/runAsTask.ts +++ b/src/features/execution/runAsTask.ts @@ -8,10 +8,10 @@ import { Uri, WorkspaceFolder, } from 'vscode'; -import { PythonTaskExecutionOptions } from '../../api'; -import { getWorkspaceFolder } from '../../common/workspace.apis'; -import { PythonEnvironment } from '../../api'; +import { PythonEnvironment, PythonTaskExecutionOptions } from '../../api'; import { executeTask } from '../../common/tasks.apis'; +import { getWorkspaceFolder } from '../../common/workspace.apis'; +import { quoteArg } from './execUtils'; function getWorkspaceFolderOrDefault(uri?: Uri): WorkspaceFolder | TaskScope { const workspace = uri ? getWorkspaceFolder(uri) : undefined; @@ -25,8 +25,8 @@ export async function runAsTask( ): Promise { const workspace: WorkspaceFolder | TaskScope = getWorkspaceFolderOrDefault(options.project?.uri); - const executable = - environment.execInfo?.activatedRun?.executable ?? environment.execInfo?.run.executable ?? 'python'; + let executable = environment.execInfo?.activatedRun?.executable ?? environment.execInfo?.run.executable ?? 'python'; + executable = quoteArg(executable); const args = environment.execInfo?.activatedRun?.args ?? environment.execInfo?.run.args ?? []; const allArgs = [...args, ...options.args];