Skip to content

Commit 32f3d0b

Browse files
authored
Hide envs before looking for recommendations (#16206)
1 parent 07e9477 commit 32f3d0b

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/notebooks/controllers/kernelSource/localPythonKernelSelector.node.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class LocalPythonKernelSelector extends DisposableBase {
103103
if (!this.pythonApi || token.isCancellationRequested) {
104104
return;
105105
}
106-
this.pythonEnvPicker.recommended = findPreferredPythonEnvironment(this.notebook, this.pythonApi);
106+
this.pythonEnvPicker.recommended = findPreferredPythonEnvironment(this.notebook, this.pythonApi, filter);
107107
};
108108
const setupApi = (api?: PythonExtension) => {
109109
if (!api) {

src/notebooks/controllers/preferredKernelConnectionService.node.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,18 @@ import { isParentPath } from '../../platform/common/platform/fileUtils';
77
import { EnvironmentType } from '../../platform/pythonEnvironments/info';
88
import { getEnvironmentType } from '../../platform/interpreter/helpers';
99
import { Environment, PythonExtension } from '@vscode/python-extension';
10+
import type { PythonEnvironmentFilter } from '../../platform/interpreter/filter/filterService';
1011

1112
export function findPreferredPythonEnvironment(
1213
notebook: NotebookDocument,
13-
pythonApi: PythonExtension
14+
pythonApi: PythonExtension,
15+
filter: PythonEnvironmentFilter
1416
): Environment | undefined {
1517
// 1. Check if we have a .conda or .venv virtual env in the local workspace folder.
16-
const localEnv = findPythonEnvironmentClosestToNotebook(notebook, pythonApi.environments.known);
18+
const localEnv = findPythonEnvironmentClosestToNotebook(
19+
notebook,
20+
pythonApi.environments.known.filter((e) => !filter.isPythonEnvironmentExcluded(e))
21+
);
1722
if (localEnv) {
1823
return localEnv;
1924
}

0 commit comments

Comments
 (0)