Skip to content
Merged
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
25 changes: 12 additions & 13 deletions src/client/terminals/codeExecution/codeExecutionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { inject, injectable } from 'inversify';
import { Disposable, EventEmitter, Terminal, Uri } from 'vscode';

import * as path from 'path';
import { ICommandManager, IDocumentManager } from '../../common/application/types';
import { Commands } from '../../common/constants';
import '../../common/extensions';
Expand Down Expand Up @@ -130,6 +130,15 @@ export class CodeExecutionManager implements ICodeExecutionManager {
if (!fileToExecute) {
return;
}

// Check on setting terminal.executeInFileDir
const pythonSettings = this.configSettings.getSettings(file);
let cwd = pythonSettings.terminal.executeInFileDir ? path.dirname(fileToExecute.fsPath) : undefined;

// Check on setting terminal.launchArgs
const launchArgs = pythonSettings.terminal.launchArgs;
const totalArgs = [...launchArgs, fileToExecute.fsPath.fileToCommandArgumentForPythonExt()];

const fileAfterSave = await codeExecutionHelper.saveFileIfDirty(fileToExecute);
if (fileAfterSave) {
fileToExecute = fileAfterSave;
Expand All @@ -138,19 +147,9 @@ export class CodeExecutionManager implements ICodeExecutionManager {
const show = this.shouldTerminalFocusOnStart(fileToExecute);
let terminal: Terminal | undefined;
if (dedicated) {
terminal = await runInDedicatedTerminal(
fileToExecute,
[fileToExecute.fsPath.fileToCommandArgumentForPythonExt()],
undefined,
show,
);
terminal = await runInDedicatedTerminal(fileToExecute, totalArgs, cwd, show);
} else {
terminal = await runInTerminal(
fileToExecute,
[fileToExecute.fsPath.fileToCommandArgumentForPythonExt()],
undefined,
show,
);
terminal = await runInTerminal(fileToExecute, totalArgs, cwd, show);
}

if (terminal) {
Expand Down
Loading