@@ -4,7 +4,7 @@ import * as settings from '../common/configSettings';
44import { Commands , PythonLanguage } from '../common/constants' ;
55let path = require ( 'path' ) ;
66let terminal : vscode . Terminal ;
7- import { IS_WINDOWS } from '../common/utils' ;
7+ import { IS_WINDOWS } from '../common/utils' ;
88
99export function activateExecInTerminalProvider ( ) : vscode . Disposable [ ] {
1010 const disposables : vscode . Disposable [ ] = [ ] ;
@@ -50,16 +50,16 @@ function execInTerminal(fileUri?: vscode.Uri) {
5050 }
5151 terminal = terminal ? terminal : vscode . window . createTerminal ( `Python` ) ;
5252 if ( pythonSettings . terminal && pythonSettings . terminal . executeInFileDir ) {
53- const fileDirPath = path . dirname ( filePath ) . substring ( 1 ) ;
54- if ( fileDirPath !== vscode . workspace . rootPath ) {
53+ const fileDirPath = path . dirname ( filePath ) ;
54+ if ( fileDirPath !== vscode . workspace . rootPath && fileDirPath . substring ( 1 ) !== vscode . workspace . rootPath ) {
5555 terminal . sendText ( `cd "${ fileDirPath } "` ) ;
5656 }
5757 }
5858 const launchArgs = settings . PythonSettings . getInstance ( ) . terminal . launchArgs ;
5959 const launchArgsString = launchArgs . length > 0 ? " " . concat ( launchArgs . join ( " " ) ) : "" ;
6060 if ( IS_WINDOWS ) {
6161 const cmd = `"${ currentPythonPath } "${ launchArgsString } ${ filePath } ` ;
62- terminal . sendText ( cmd . replace ( / \\ / g, "/" ) ) ;
62+ terminal . sendText ( cmd . replace ( / \\ / g, "/" ) ) ;
6363 }
6464 else {
6565 terminal . sendText ( `${ currentPythonPath } ${ launchArgsString } ${ filePath } ` ) ;
@@ -89,7 +89,7 @@ function execSelectionInTerminal() {
8989 terminal . sendText ( code ) ;
9090 }
9191 else {
92- terminal . sendText ( `${ currentPythonPath } ${ launchArgsString } -c "${ code } "` ) ;
92+ terminal . sendText ( `${ currentPythonPath } ${ launchArgsString } -c "${ code } "` ) ;
9393 }
9494 terminal . show ( ) ;
9595}
0 commit comments