Skip to content

Commit b1e8a5a

Browse files
author
Kartik Raj
committed
Fxi bug
1 parent f039fc4 commit b1e8a5a

File tree

4 files changed

+20
-15
lines changed

4 files changed

+20
-15
lines changed

src/client/apiTypes.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ export interface InterpretersChangedParams {
104104
}
105105

106106
export interface ActiveInterpreterChangedParams {
107-
interpreterPath?: string;
107+
/**
108+
* Interpreter path or environment path that uniquely identifies an environment.
109+
*/
110+
path?: string;
108111
resource?: Uri;
109112
}
110113

src/client/interpreter/display/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ export class InterpreterDisplay implements IInterpreterDisplay, IExtensionSingle
109109
}
110110
private async updateDisplay(workspaceFolder?: Uri) {
111111
const interpreter = await this.interpreterService.getActiveInterpreter(workspaceFolder);
112+
if (
113+
this.currentlySelectedInterpreterDisplay &&
114+
this.currentlySelectedInterpreterDisplay === interpreter?.detailedDisplayName
115+
) {
116+
return;
117+
}
112118
this.currentlySelectedWorkspaceFolder = workspaceFolder;
113119
if (this.statusBar) {
114120
if (interpreter) {

src/client/interpreter/interpreterService.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class InterpreterService implements Disposable, IInterpreterService {
6060
return this.didChangeInterpreterConfigurationEmitter.event;
6161
}
6262

63-
public _currentInterpreterDisplay: string | undefined = '';
63+
public _pythonPathSetting: string | undefined = '';
6464

6565
private readonly didChangeInterpreterConfigurationEmitter = new EventEmitter<Uri | undefined>();
6666

@@ -158,20 +158,16 @@ export class InterpreterService implements Disposable, IInterpreterService {
158158
public async _onConfigChanged(resource?: Uri): Promise<void> {
159159
this.didChangeInterpreterConfigurationEmitter.fire(resource);
160160
// Check if we actually changed our python path
161-
const interpreter = await this.getActiveInterpreter(resource);
162-
if (
163-
this._currentInterpreterDisplay === '' ||
164-
this._currentInterpreterDisplay !== interpreter?.detailedDisplayName
165-
) {
166-
this._currentInterpreterDisplay = interpreter?.detailedDisplayName;
161+
const pySettings = this.configService.getSettings(resource);
162+
if (this._pythonPathSetting === '' || this._pythonPathSetting !== pySettings.pythonPath) {
163+
this._pythonPathSetting = pySettings.pythonPath;
167164
this.didChangeInterpreterEmitter.fire();
168-
const pySettings = this.configService.getSettings(resource);
169165
reportActiveInterpreterChanged({
170-
interpreterPath: pySettings.pythonPath === '' ? undefined : pySettings.pythonPath,
166+
path: pySettings.pythonPath === '' ? undefined : pySettings.pythonPath,
171167
resource,
172168
});
173-
const interpreterDisplay = this.serviceContainer.get<IInterpreterDisplay>(IInterpreterDisplay);
174-
interpreterDisplay.refresh().catch((ex) => traceError('Python Extension: display.refresh', ex));
175169
}
170+
const interpreterDisplay = this.serviceContainer.get<IInterpreterDisplay>(IInterpreterDisplay);
171+
interpreterDisplay.refresh().catch((ex) => traceError('Python Extension: display.refresh', ex));
176172
}
177173
}

src/test/interpreters/interpreterService.unit.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ suite('Interpreters service', () => {
248248
test('If stored setting is an empty string, refresh the interpreter display', async () => {
249249
const service = new InterpreterService(serviceContainer, pyenvs.object);
250250
const resource = Uri.parse('a');
251-
service._currentInterpreterDisplay = '';
251+
service._pythonPathSetting = '';
252252
configService.reset();
253253
configService.setup((c) => c.getSettings(resource)).returns(() => ({ pythonPath: 'current path' } as any));
254254
interpreterDisplay
@@ -266,7 +266,7 @@ suite('Interpreters service', () => {
266266
test('If stored setting is not equal to current interpreter path setting, refresh the interpreter display', async () => {
267267
const service = new InterpreterService(serviceContainer, pyenvs.object);
268268
const resource = Uri.parse('a');
269-
service._currentInterpreterDisplay = 'stored setting';
269+
service._pythonPathSetting = 'stored setting';
270270
configService.reset();
271271
configService.setup((c) => c.getSettings(resource)).returns(() => ({ pythonPath: 'current path' } as any));
272272
interpreterDisplay
@@ -284,7 +284,7 @@ suite('Interpreters service', () => {
284284
test('If stored setting is equal to current interpreter path setting, do not refresh the interpreter display', async () => {
285285
const service = new InterpreterService(serviceContainer, pyenvs.object);
286286
const resource = Uri.parse('a');
287-
service._currentInterpreterDisplay = 'setting';
287+
service._pythonPathSetting = 'setting';
288288
configService.reset();
289289
configService.setup((c) => c.getSettings(resource)).returns(() => ({ pythonPath: 'setting' } as any));
290290
interpreterDisplay

0 commit comments

Comments
 (0)