Skip to content

Commit d7bc12a

Browse files
committed
respect setting defaultInterpreterPath for execute with envs ext
1 parent 167e6e7 commit d7bc12a

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/client/envExt/api.internal.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,15 @@ export async function runInTerminal(
8989
args?: string[],
9090
cwd?: string | Uri,
9191
show?: boolean,
92+
interpreterPath?: string,
9293
): Promise<Terminal> {
9394
const envExtApi = await getEnvExtApi();
94-
const env = await getEnvironment(resource);
95+
let env;
96+
if (interpreterPath) {
97+
env = await envExtApi.resolveEnvironment(Uri.file(interpreterPath));
98+
} else {
99+
env = await getEnvironment(resource);
100+
}
95101
const project = resource ? envExtApi.getPythonProject(resource) : undefined;
96102
if (env && resource) {
97103
return envExtApi.runInTerminal(env, {
@@ -108,9 +114,15 @@ export async function runInDedicatedTerminal(
108114
args?: string[],
109115
cwd?: string | Uri,
110116
show?: boolean,
117+
interpreterPath?: string,
111118
): Promise<Terminal> {
112119
const envExtApi = await getEnvExtApi();
113-
const env = await getEnvironment(resource);
120+
let env;
121+
if (interpreterPath) {
122+
env = await envExtApi.resolveEnvironment(Uri.file(interpreterPath));
123+
} else {
124+
env = await getEnvironment(resource);
125+
}
114126
const project = resource ? envExtApi.getPythonProject(resource) : undefined;
115127
if (env) {
116128
return envExtApi.runInDedicatedTerminal(resource ?? 'global', env, {

src/client/terminals/codeExecution/codeExecutionManager.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ export class CodeExecutionManager implements ICodeExecutionManager {
130130
if (!fileToExecute) {
131131
return;
132132
}
133+
134+
const pythonSettings = this.configSettings.getSettings(file);
135+
136+
// Check on setting python.defaultInterpreterPath
137+
const defaultInterpreterPath = pythonSettings.defaultInterpreterPath;
138+
133139
const fileAfterSave = await codeExecutionHelper.saveFileIfDirty(fileToExecute);
134140
if (fileAfterSave) {
135141
fileToExecute = fileAfterSave;
@@ -143,13 +149,15 @@ export class CodeExecutionManager implements ICodeExecutionManager {
143149
[fileToExecute.fsPath.fileToCommandArgumentForPythonExt()],
144150
undefined,
145151
show,
152+
defaultInterpreterPath,
146153
);
147154
} else {
148155
terminal = await runInTerminal(
149156
fileToExecute,
150157
[fileToExecute.fsPath.fileToCommandArgumentForPythonExt()],
151158
undefined,
152159
show,
160+
defaultInterpreterPath,
153161
);
154162
}
155163

0 commit comments

Comments
 (0)