Skip to content

Commit 759e4de

Browse files
committed
#fix #514
1 parent dca874b commit 759e4de

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/client/providers/execInTerminalProvider.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as settings from '../common/configSettings';
44
import { Commands, PythonLanguage } from '../common/constants';
55
let path = require('path');
66
let terminal: vscode.Terminal;
7-
import {IS_WINDOWS} from '../common/utils';
7+
import { IS_WINDOWS } from '../common/utils';
88

99
export 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

Comments
 (0)