From b8b12dd0d0822f1e26f90523124f302818931cde Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Sun, 23 Jul 2023 22:35:57 -0700 Subject: [PATCH] Ensure `Run Python in dedicated terminal` uses `python.executeInFirDir` setting --- .../base/locators/lowLevel/windowsKnownPathsLocator.ts | 6 ++++-- .../terminals/codeExecution/terminalCodeExecution.ts | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/client/pythonEnvironments/base/locators/lowLevel/windowsKnownPathsLocator.ts b/src/client/pythonEnvironments/base/locators/lowLevel/windowsKnownPathsLocator.ts index 337a8fb09a97..5bfc62d99d48 100644 --- a/src/client/pythonEnvironments/base/locators/lowLevel/windowsKnownPathsLocator.ts +++ b/src/client/pythonEnvironments/base/locators/lowLevel/windowsKnownPathsLocator.ts @@ -94,8 +94,10 @@ function getDirFilesLocator( // take a naive approach. async function* iterEnvs(query: PythonLocatorQuery): IPythonEnvsIterator { 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, diff --git a/src/client/terminals/codeExecution/terminalCodeExecution.ts b/src/client/terminals/codeExecution/terminalCodeExecution.ts index 4c329e939599..50270c3586c4 100644 --- a/src/client/terminals/codeExecution/terminalCodeExecution.ts +++ b/src/client/terminals/codeExecution/terminalCodeExecution.ts @@ -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(), ]); @@ -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; @@ -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()}`, + ); } } }