Skip to content

feat: add python.terminal.commandPrefix setting for custom file runners - #26321

Open
MOHAMMED WASIM KHAN (wasim-builds) wants to merge 1 commit into
microsoft:mainfrom
wasim-builds:feat/issue-26319
Open

MOHAMMED WASIM KHAN (wasim-builds) wants to merge 1 commit into
microsoft:mainfrom
wasim-builds:feat/issue-26319

Conversation

@wasim-builds

@wasim-builds MOHAMMED WASIM KHAN (wasim-builds) commented Nov 29, 2026 •

Copy link
Copy Markdown

Fixes #26319

Summary

Adds the python.terminal.commandPrefix resource-scoped setting (default []) so users can configure a custom runner prefix such as ["uv", "run"] or ["poetry", "run"] when executing Python files via the Run Python File command / Play button.

Changes

  • package.json & package.nls.json: Added python.terminal.commandPrefix (string[], resource-scoped) and its localization description.
  • src/client/common/types.ts & src/client/common/configSettings.ts: Added commandPrefix?: string[] to ITerminalSettings and fallback initialization.
  • src/client/terminals/codeExecution/terminalCodeExecution.ts: Added getNormalizedCommandPrefix() and updated TerminalCodeExecutionProvider.getExecuteFileArgs() to invoke the configured runner prefix (followed by terminal.launchArgs and the target file) when non-empty, falling back to the active Python interpreter when unset or blank.
  • src/client/terminals/codeExecution/codeExecutionManager.ts: Updated CodeExecutionManager.executeUsingExtension() to delegate to the standard ICodeExecutionService when python.terminal.commandPrefix is configured so custom runners also work when the Python Environments extension is enabled.
  • Unit Tests: Added unit tests in terminalCodeExec.unit.test.ts and codeExecutionManager.unit.test.ts.

Verification

  • npx tsc -p tsconfig.json: passed (0 errors)
  • npx eslint on all modified TS files: passed (0 errors)
  • npx mocha --require out/test/unittests.js --ui tdd --timeout 180000 out/test/terminals/codeExecution/terminalCodeExec.unit.test.js out/test/terminals/codeExecution/codeExecutionManager.unit.test.js: 113 passing (113/113)

Copilot AI balanced review requested due to automatic review settings November 29, 2026 09:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

With Python Environments enabled, unescaped shell substitutions in script filenames can execute unintended commands rather than pass the filename literally.

4 open issues
What changed in this PR

Adds python.terminal.commandPrefix so Run Python File and the editor Play button can use custom runners such as uv run, addressing #26319 while preserving interpreter execution when the setting is empty.

Changes:

  • Defines a resource-scoped runner-prefix setting with an empty default.
  • Adds prefix normalization and execution routing, including when Python Environments is enabled.
  • Adds unit tests for custom prefixes, whitespace handling, interpreter fallback, and execution delegation.
File Description
src/​test/​terminals/​codeExecution/​terminalCodeExec.unit.test.ts Tests custom runners, normalization, and fallback.
src/​test/​terminals/​codeExecution/​codeExecutionManager.unit.test.ts Tests delegation when a prefix is configured.
src/​client/​terminals/​codeExecution/​terminalCodeExecution.ts Normalizes prefixes and builds custom-runner commands.
src/​client/​terminals/​codeExecution/​codeExecutionManager.ts Routes configured runners through the standard execution service.
src/​client/​common/​types.ts Adds the optional terminal prefix property.
src/​client/​common/​configSettings.ts Initializes the fallback prefix to an empty array.
package.nls.json Adds the setting’s localized description.
package.json Registers the resource-scoped string-array setting.

Review effort: Balanced

ICodeExecutionService,
'standard',
);
await executionService.executeFile(fileToExecute, { newTerminalPerFile: dedicated });

// Check on setting terminal.executeInFileDir
// Check on setting terminal.commandPrefix
const pythonSettings = this.configSettings.getSettings(file);
ICodeExecutionService,
'standard',
);
await executionService.executeFile(fileToExecute, { newTerminalPerFile: dedicated });
ICodeExecutionService,
'standard',
);
await executionService.executeFile(fileToExecute, { newTerminalPerFile: dedicated });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow configuring a custom runner command e.g., uv run for the Play button

2 participants