Skip to content

Commit

Permalink
Ensure Run Python in dedicated terminal uses `python.executeInFirDi…
Browse files Browse the repository at this point in the history
…r` setting (#21681)
  • Loading branch information
Kartik Raj committed Jul 24, 2023
1 parent 713007f commit 9bcb82d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@ function getDirFilesLocator(
// take a naive approach.
async function* iterEnvs(query: PythonLocatorQuery): IPythonEnvsIterator<BasicEnvInfo> {
traceVerbose('Searching for windows path interpreters');
yield* await getEnvs(locator.iterEnvs(query));
traceVerbose('Finished searching for windows path interpreters');
yield* await getEnvs(locator.iterEnvs(query)).then((res) => {
traceVerbose('Finished searching for windows path interpreters');
return res;
});
}
return {
providerId: locator.providerId,
Expand Down
8 changes: 5 additions & 3 deletions src/client/terminals/codeExecution/terminalCodeExecution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class TerminalCodeExecutionProvider implements ICodeExecutionService {
) {}

public async executeFile(file: Uri, options?: { newTerminalPerFile: boolean }) {
await this.setCwdForFileExecution(file);
await this.setCwdForFileExecution(file, options);
const { command, args } = await this.getExecuteFileArgs(file, [
file.fsPath.fileToCommandArgumentForPythonExt(),
]);
Expand Down Expand Up @@ -88,7 +88,7 @@ export class TerminalCodeExecutionProvider implements ICodeExecutionService {
newTerminalPerFile: options?.newTerminalPerFile,
});
}
private async setCwdForFileExecution(file: Uri) {
private async setCwdForFileExecution(file: Uri, options?: { newTerminalPerFile: boolean }) {
const pythonSettings = this.configurationService.getSettings(file);
if (!pythonSettings.terminal.executeInFileDir) {
return;
Expand All @@ -106,7 +106,9 @@ export class TerminalCodeExecutionProvider implements ICodeExecutionService {
await this.getTerminalService(file).sendText(`${fileDrive}:`);
}
}
await this.getTerminalService(file).sendText(`cd ${fileDirPath.fileToCommandArgumentForPythonExt()}`);
await this.getTerminalService(file, options).sendText(
`cd ${fileDirPath.fileToCommandArgumentForPythonExt()}`,
);
}
}
}

0 comments on commit 9bcb82d

Please sign in to comment.