Skip to content

Commit 39d7ecd

Browse files
author
Kartik Raj
committed
Fxi bug
1 parent b39f728 commit 39d7ecd

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
@@ -62,7 +62,7 @@ export class InterpreterService implements Disposable, IInterpreterService {
6262
return this.didChangeInterpreterConfigurationEmitter.event;
6363
}
6464

65-
public _currentInterpreterDisplay: string | undefined = '';
65+
public _pythonPathSetting: string | undefined = '';
6666

6767
private readonly didChangeInterpreterConfigurationEmitter = new EventEmitter<Uri | undefined>();
6868

@@ -180,20 +180,16 @@ export class InterpreterService implements Disposable, IInterpreterService {
180180
public async _onConfigChanged(resource?: Uri): Promise<void> {
181181
this.didChangeInterpreterConfigurationEmitter.fire(resource);
182182
// Check if we actually changed our python path
183-
const interpreter = await this.getActiveInterpreter(resource);
184-
if (
185-
this._currentInterpreterDisplay === '' ||
186-
this._currentInterpreterDisplay !== interpreter?.detailedDisplayName
187-
) {
188-
this._currentInterpreterDisplay = interpreter?.detailedDisplayName;
183+
const pySettings = this.configService.getSettings(resource);
184+
if (this._pythonPathSetting === '' || this._pythonPathSetting !== pySettings.pythonPath) {
185+
this._pythonPathSetting = pySettings.pythonPath;
189186
this.didChangeInterpreterEmitter.fire();
190-
const pySettings = this.configService.getSettings(resource);
191187
reportActiveInterpreterChanged({
192-
interpreterPath: pySettings.pythonPath === '' ? undefined : pySettings.pythonPath,
188+
path: pySettings.pythonPath === '' ? undefined : pySettings.pythonPath,
193189
resource,
194190
});
195-
const interpreterDisplay = this.serviceContainer.get<IInterpreterDisplay>(IInterpreterDisplay);
196-
interpreterDisplay.refresh().catch((ex) => traceError('Python Extension: display.refresh', ex));
197191
}
192+
const interpreterDisplay = this.serviceContainer.get<IInterpreterDisplay>(IInterpreterDisplay);
193+
interpreterDisplay.refresh().catch((ex) => traceError('Python Extension: display.refresh', ex));
198194
}
199195
}

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)