Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure Run Python in dedicated terminal uses python.executeInFirDir setting #21681

Merged
merged 1 commit into from
Jul 24, 2023
Merged
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
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()}`,
);
}
}
}