Skip to content
Draft
Show file tree
Hide file tree
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
16 changes: 14 additions & 2 deletions src/client/envExt/api.internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,15 @@ export async function runInTerminal(
args?: string[],
cwd?: string | Uri,
show?: boolean,
interpreterPath?: string,
): Promise<Terminal> {
const envExtApi = await getEnvExtApi();
const env = await getEnvironment(resource);
let env;
if (interpreterPath) {
env = await envExtApi.resolveEnvironment(Uri.file(interpreterPath));
} else {
env = await getEnvironment(resource);
}
const project = resource ? envExtApi.getPythonProject(resource) : undefined;
if (env && resource) {
return envExtApi.runInTerminal(env, {
Expand All @@ -108,9 +114,15 @@ export async function runInDedicatedTerminal(
args?: string[],
cwd?: string | Uri,
show?: boolean,
interpreterPath?: string,
): Promise<Terminal> {
const envExtApi = await getEnvExtApi();
const env = await getEnvironment(resource);
let env;
if (interpreterPath) {
env = await envExtApi.resolveEnvironment(Uri.file(interpreterPath));
} else {
env = await getEnvironment(resource);
}
const project = resource ? envExtApi.getPythonProject(resource) : undefined;
if (env) {
return envExtApi.runInDedicatedTerminal(resource ?? 'global', env, {
Expand Down
8 changes: 8 additions & 0 deletions src/client/terminals/codeExecution/codeExecutionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ export class CodeExecutionManager implements ICodeExecutionManager {
if (!fileToExecute) {
return;
}

const pythonSettings = this.configSettings.getSettings(file);

// Check on setting python.defaultInterpreterPath
const defaultInterpreterPath = pythonSettings.defaultInterpreterPath;

const fileAfterSave = await codeExecutionHelper.saveFileIfDirty(fileToExecute);
if (fileAfterSave) {
fileToExecute = fileAfterSave;
Expand All @@ -143,13 +149,15 @@ export class CodeExecutionManager implements ICodeExecutionManager {
[fileToExecute.fsPath.fileToCommandArgumentForPythonExt()],
undefined,
show,
defaultInterpreterPath,
);
} else {
terminal = await runInTerminal(
fileToExecute,
[fileToExecute.fsPath.fileToCommandArgumentForPythonExt()],
undefined,
show,
defaultInterpreterPath,
);
}

Expand Down
Loading