Skip to content

Commit 1eafdb5

Browse files
authored
add quoting logic in runAsTask (#651)
might fix #642, waiting on clarification
1 parent 6e0b196 commit 1eafdb5

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/features/execution/execUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function quoteArg(arg: string): string {
1+
export function quoteArg(arg: string): string {
22
if (arg.indexOf(' ') >= 0 && !(arg.startsWith('"') && arg.endsWith('"'))) {
33
return `"${arg}"`;
44
}

src/features/execution/runAsTask.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import {
88
Uri,
99
WorkspaceFolder,
1010
} from 'vscode';
11-
import { PythonTaskExecutionOptions } from '../../api';
12-
import { getWorkspaceFolder } from '../../common/workspace.apis';
13-
import { PythonEnvironment } from '../../api';
11+
import { PythonEnvironment, PythonTaskExecutionOptions } from '../../api';
1412
import { executeTask } from '../../common/tasks.apis';
13+
import { getWorkspaceFolder } from '../../common/workspace.apis';
14+
import { quoteArg } from './execUtils';
1515

1616
function getWorkspaceFolderOrDefault(uri?: Uri): WorkspaceFolder | TaskScope {
1717
const workspace = uri ? getWorkspaceFolder(uri) : undefined;
@@ -25,8 +25,8 @@ export async function runAsTask(
2525
): Promise<TaskExecution> {
2626
const workspace: WorkspaceFolder | TaskScope = getWorkspaceFolderOrDefault(options.project?.uri);
2727

28-
const executable =
29-
environment.execInfo?.activatedRun?.executable ?? environment.execInfo?.run.executable ?? 'python';
28+
let executable = environment.execInfo?.activatedRun?.executable ?? environment.execInfo?.run.executable ?? 'python';
29+
executable = quoteArg(executable);
3030
const args = environment.execInfo?.activatedRun?.args ?? environment.execInfo?.run.args ?? [];
3131
const allArgs = [...args, ...options.args];
3232

0 commit comments

Comments
 (0)