Skip to content

Commit 9bcb82d

Browse files
author
Kartik Raj
authored
Ensure Run Python in dedicated terminal uses python.executeInFirDir setting (#21681)
1 parent 713007f commit 9bcb82d

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/client/pythonEnvironments/base/locators/lowLevel/windowsKnownPathsLocator.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,10 @@ function getDirFilesLocator(
9494
// take a naive approach.
9595
async function* iterEnvs(query: PythonLocatorQuery): IPythonEnvsIterator<BasicEnvInfo> {
9696
traceVerbose('Searching for windows path interpreters');
97-
yield* await getEnvs(locator.iterEnvs(query));
98-
traceVerbose('Finished searching for windows path interpreters');
97+
yield* await getEnvs(locator.iterEnvs(query)).then((res) => {
98+
traceVerbose('Finished searching for windows path interpreters');
99+
return res;
100+
});
99101
}
100102
return {
101103
providerId: locator.providerId,

src/client/terminals/codeExecution/terminalCodeExecution.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class TerminalCodeExecutionProvider implements ICodeExecutionService {
3030
) {}
3131

3232
public async executeFile(file: Uri, options?: { newTerminalPerFile: boolean }) {
33-
await this.setCwdForFileExecution(file);
33+
await this.setCwdForFileExecution(file, options);
3434
const { command, args } = await this.getExecuteFileArgs(file, [
3535
file.fsPath.fileToCommandArgumentForPythonExt(),
3636
]);
@@ -88,7 +88,7 @@ export class TerminalCodeExecutionProvider implements ICodeExecutionService {
8888
newTerminalPerFile: options?.newTerminalPerFile,
8989
});
9090
}
91-
private async setCwdForFileExecution(file: Uri) {
91+
private async setCwdForFileExecution(file: Uri, options?: { newTerminalPerFile: boolean }) {
9292
const pythonSettings = this.configurationService.getSettings(file);
9393
if (!pythonSettings.terminal.executeInFileDir) {
9494
return;
@@ -106,7 +106,9 @@ export class TerminalCodeExecutionProvider implements ICodeExecutionService {
106106
await this.getTerminalService(file).sendText(`${fileDrive}:`);
107107
}
108108
}
109-
await this.getTerminalService(file).sendText(`cd ${fileDirPath.fileToCommandArgumentForPythonExt()}`);
109+
await this.getTerminalService(file, options).sendText(
110+
`cd ${fileDirPath.fileToCommandArgumentForPythonExt()}`,
111+
);
110112
}
111113
}
112114
}

0 commit comments

Comments
 (0)