Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix compatibility with ms-python #915

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store
npm-debug.log
out
node_modules
node_modules
yarn.lock
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,12 @@
"description": "Whether to run code in Integrated Terminal.",
"scope": "resource"
},
"code-runner.runWithPythonExtension": {
"type": "boolean",
"default": false,
"description": "Whether to run Python code with ms-python extension",
"scope": "resource"
},
"code-runner.terminalRoot": {
"type": "string",
"default": "",
Expand Down
10 changes: 10 additions & 0 deletions src/codeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,16 @@ export class CodeManager implements vscode.Disposable {
}

private async executeCommandInTerminal(executor: string, appendFile: boolean = true) {
if (this._config.get<boolean>("runWithPythonExtension") && executor.startsWith('python')) {
const python_ext = vscode.extensions.getExtension('ms-python.python');
if (python_ext?.isActive) {
await vscode.commands.executeCommand('python.execInTerminal');
return;
} else {
vscode.window.showErrorMessage('ms-python did not activated');
return;
}
}
let isNewTerminal = false;
if (this._terminal === null) {
this._terminal = vscode.window.createTerminal("Code");
Expand Down