File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 117117 {
118118 "command" : " python.runtests" ,
119119 "group" : " Python"
120+ },
121+ {
122+ "when" : " resourceLangId == python" ,
123+ "command" : " python.execInTerminal" ,
124+ "group" : " Python"
120125 }
121126 ]
122127 },
Original file line number Diff line number Diff 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 ( ( ) => {
You can’t perform that action at this time.
0 commit comments