1
1
// Copyright (c) Microsoft Corporation. All rights reserved.
2
2
// Licensed under the MIT License.
3
3
4
- import { isEqual } from 'lodash' ;
4
+ import { cloneDeep , isEqual } from 'lodash' ;
5
5
import { Event , EventEmitter } from 'vscode' ;
6
6
import { traceVerbose } from '../../common/logger' ;
7
7
import { areSameEnvironment , PythonEnvInfo , PythonEnvKind } from '../base/info' ;
@@ -94,6 +94,8 @@ async function resolveDifferencesInBackground(
94
94
if ( ! isEqual ( oldEnv , merged ) ) {
95
95
didUpdate . fire ( { old : oldEnv , new : merged } ) ;
96
96
seen [ oldIndex ] = merged ;
97
+ } else {
98
+ const x = 2 ;
97
99
}
98
100
state . pending -= 1 ;
99
101
checkIfFinishedAndNotify ( state , didUpdate ) ;
@@ -115,10 +117,11 @@ function checkIfFinishedAndNotify(
115
117
}
116
118
117
119
export function mergeEnvironments ( environment : PythonEnvInfo , other : PythonEnvInfo ) : PythonEnvInfo {
120
+ const result = cloneDeep ( environment ) ;
118
121
// Preserve type information.
119
122
// Possible we identified environment as unknown, but a later provider has identified env type.
120
123
if ( environment . kind === PythonEnvKind . Unknown && other . kind && other . kind !== PythonEnvKind . Unknown ) {
121
- environment . kind = other . kind ;
124
+ result . kind = other . kind ;
122
125
}
123
126
const props : ( keyof PythonEnvInfo ) [ ] = [
124
127
'version' ,
@@ -131,11 +134,11 @@ export function mergeEnvironments(environment: PythonEnvInfo, other: PythonEnvIn
131
134
'searchLocation' ,
132
135
] ;
133
136
props . forEach ( ( prop ) => {
134
- if ( ! environment [ prop ] && other [ prop ] ) {
137
+ if ( ! result [ prop ] && other [ prop ] ) {
135
138
// tslint:disable: no-any
136
139
// eslint-disable-next-line @typescript-eslint/no-explicit-any
137
- ( environment as any ) [ prop ] = other [ prop ] ;
140
+ ( result as any ) [ prop ] = other [ prop ] ;
138
141
}
139
142
} ) ;
140
- return environment ;
143
+ return result ;
141
144
}
0 commit comments