Skip to content

Commit 16f04fb

Browse files
authored
switch to using inspect for setting to check for user explicit value (microsoft#803)
based on what we discussed yesterday, this will correctly use inspect to get the value of `defaultEnvManager` to know if the user has set it yet
1 parent c64eac0 commit 16f04fb

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/extension.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -596,15 +596,9 @@ export async function disposeAll(disposables: IDisposable[]): Promise<void> {
596596
}
597597

598598
/**
599-
* Resolves and sets the default Python interpreter for the workspace based on the
600-
* 'python.defaultInterpreterPath' setting and the selected environment manager.
601-
* If the setting is present and no default environment manager is set (or is venv),
602-
* attempts to resolve the interpreter path using the native finder. If the resolved
603-
* path differs from the configured path, then creates and sets a PythonEnvironment
604-
* object for the workspace.
605-
*
606-
* @param nativeFinder - The NativePythonFinder instance used to resolve interpreter paths.
607-
* @param envManagers - The EnvironmentManagers instance containing all registered managers.
599+
* Sets the default Python interpreter for the workspace if the user has not explicitly set 'defaultEnvManager' or it is set to venv.
600+
* @param nativeFinder - used to resolve interpreter paths.
601+
* @param envManagers - contains all registered managers.
608602
* @param api - The PythonEnvironmentApi for environment resolution and setting.
609603
*/
610604
async function resolveDefaultInterpreter(
@@ -615,9 +609,13 @@ async function resolveDefaultInterpreter(
615609
const defaultInterpreterPath = getConfiguration('python').get<string>('defaultInterpreterPath');
616610

617611
if (defaultInterpreterPath) {
618-
const defaultManager = getConfiguration('python-envs').get<string>('defaultEnvManager', 'undefined');
619-
traceInfo(`resolveDefaultInterpreter setting exists; found defaultEnvManager: ${defaultManager}. `);
620-
if (!defaultManager || defaultManager === 'ms-python.python:venv') {
612+
const config = getConfiguration('python-envs');
613+
const inspect = config.inspect<string>('defaultEnvManager');
614+
const userDefinedDefaultManager =
615+
inspect?.workspaceFolderValue !== undefined ||
616+
inspect?.workspaceValue !== undefined ||
617+
inspect?.globalValue !== undefined;
618+
if (!userDefinedDefaultManager) {
621619
try {
622620
const resolved: NativeEnvInfo = await nativeFinder.resolve(defaultInterpreterPath);
623621
if (resolved && resolved.executable) {

0 commit comments

Comments
 (0)