Skip to content

Commit 3df36ec

Browse files
authored
bug: use executeInFileDir and launchArgs settings with envs ext (#25405)
helps with a part of microsoft/vscode-python-environments#709
1 parent 167e6e7 commit 3df36ec

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/client/terminals/codeExecution/codeExecutionManager.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { inject, injectable } from 'inversify';
77
import { Disposable, EventEmitter, Terminal, Uri } from 'vscode';
8-
8+
import * as path from 'path';
99
import { ICommandManager, IDocumentManager } from '../../common/application/types';
1010
import { Commands } from '../../common/constants';
1111
import '../../common/extensions';
@@ -130,6 +130,15 @@ export class CodeExecutionManager implements ICodeExecutionManager {
130130
if (!fileToExecute) {
131131
return;
132132
}
133+
134+
// Check on setting terminal.executeInFileDir
135+
const pythonSettings = this.configSettings.getSettings(file);
136+
let cwd = pythonSettings.terminal.executeInFileDir ? path.dirname(fileToExecute.fsPath) : undefined;
137+
138+
// Check on setting terminal.launchArgs
139+
const launchArgs = pythonSettings.terminal.launchArgs;
140+
const totalArgs = [...launchArgs, fileToExecute.fsPath.fileToCommandArgumentForPythonExt()];
141+
133142
const fileAfterSave = await codeExecutionHelper.saveFileIfDirty(fileToExecute);
134143
if (fileAfterSave) {
135144
fileToExecute = fileAfterSave;
@@ -138,19 +147,9 @@ export class CodeExecutionManager implements ICodeExecutionManager {
138147
const show = this.shouldTerminalFocusOnStart(fileToExecute);
139148
let terminal: Terminal | undefined;
140149
if (dedicated) {
141-
terminal = await runInDedicatedTerminal(
142-
fileToExecute,
143-
[fileToExecute.fsPath.fileToCommandArgumentForPythonExt()],
144-
undefined,
145-
show,
146-
);
150+
terminal = await runInDedicatedTerminal(fileToExecute, totalArgs, cwd, show);
147151
} else {
148-
terminal = await runInTerminal(
149-
fileToExecute,
150-
[fileToExecute.fsPath.fileToCommandArgumentForPythonExt()],
151-
undefined,
152-
show,
153-
);
152+
terminal = await runInTerminal(fileToExecute, totalArgs, cwd, show);
154153
}
155154

156155
if (terminal) {

0 commit comments

Comments
 (0)