Skip to content

Commit 1d78651

Browse files
jaboothDonJayamanne
authored andcommitted
Add right-click explorer Exec in Terminal
1 parent 7e7204f commit 1d78651

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

‎package.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@
117117
{
118118
"command": "python.runtests",
119119
"group": "Python"
120+
},
121+
{
122+
"when": "resourceLangId == python",
123+
"command": "python.execInTerminal",
124+
"group": "Python"
120125
}
121126
]
122127
},

‎src/client/providers/execInTerminalProvider.ts‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ export function activateExecInTerminalProvider() {
66
vscode.commands.registerCommand("python.execInTerminal", execInTerminal);
77
}
88

9-
function execInTerminal(filePath: string) {
9+
function execInTerminal(fileUri?: vscode.Uri) {
1010
const currentPythonPath = settings.PythonSettings.getInstance().pythonPath;
11+
let filePath: string;
1112

12-
console.log(filePath);
13-
if (filePath === undefined) {
13+
console.log(fileUri);
14+
if (fileUri === undefined) {
1415
const activeEditor = vscode.window.activeTextEditor;
1516
if (activeEditor !== undefined) {
1617
if (!activeEditor.document.isUntitled) {
@@ -23,9 +24,11 @@ function execInTerminal(filePath: string) {
2324
vscode.window.showErrorMessage('No open file to run in terminal');
2425
return;
2526
}
27+
} else {
28+
filePath = fileUri.fsPath;
2629
}
2730

28-
const terminal = (<any>vscode.window).createTerminal(`Ext Terminal`);
31+
const terminal = (<any>vscode.window).createTerminal(`Python`);
2932
// Temporary workaround until a promise of terminal readiness is available:
3033
// https://github.com/Tyriar/vscode-terminal-api-example/issues/2
3134
setTimeout(() => {

0 commit comments

Comments
 (0)