Skip to content

Commit 134b81d

Browse files
author
Kartik Raj
committed
Correctly compare environment objects
1 parent 2efb288 commit 134b81d

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

src/client/common/utils/version.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,6 @@ export const EMPTY_VERSION: RawBasicVersionInfo = {
7070
major: -1,
7171
minor: -1,
7272
micro: -1,
73-
unnormalized: {
74-
major: undefined,
75-
minor: undefined,
76-
micro: undefined,
77-
},
7873
};
7974
Object.freeze(EMPTY_VERSION);
8075

src/client/extension.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ async function activateUnsafe(
159159

160160
const api = buildApi(activationPromise, ext.legacyIOC.serviceManager, ext.legacyIOC.serviceContainer);
161161
const proposedApi = buildProposedApi(components.pythonEnvs, ext.legacyIOC.serviceContainer);
162+
proposedApi.environment.onDidChangeEnvironments((e) => {
163+
console.log(JSON.stringify({ type: e.type, env: e.env.path }));
164+
});
162165
return [{ ...api, ...proposedApi }, activationPromise, ext.legacyIOC.serviceContainer];
163166
}
164167

src/client/pythonEnvironments/base/info/env.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,16 @@ export function buildEnvInfo(init?: {
7878
}
7979

8080
export function areEnvsDeepEqual(env1: PythonEnvInfo, env2: PythonEnvInfo): boolean {
81-
env1.source = env1.source.sort();
82-
env2.source = env2.source.sort();
83-
return isEqual(env1, env2);
81+
const env1Clone = cloneDeep(env1);
82+
const env2Clone = cloneDeep(env2);
83+
// Cannot compare searchLocation as they are Uri objects.
84+
delete env1Clone.searchLocation;
85+
delete env2Clone.searchLocation;
86+
env1Clone.source = env1Clone.source.sort();
87+
env2Clone.source = env2Clone.source.sort();
88+
const searchLocation1 = env1.searchLocation?.fsPath ?? '';
89+
const searchLocation2 = env2.searchLocation?.fsPath ?? '';
90+
return isEqual(env1Clone, env2Clone) && arePathsSame(searchLocation1, searchLocation2);
8491
}
8592

8693
/**

0 commit comments

Comments
 (0)