Add support for dynamic updates in interpreter list#17043
Add support for dynamic updates in interpreter list#17043karrtikr merged 19 commits intomicrosoft:mainfrom
Conversation
07c95c5 to
d1c9d31
Compare
a8485cb to
c38f2b0
Compare
2093a8f to
0e5dece
Compare
| const invalidIndexes = areEnvsValid.map((isValid, index) => (isValid ? -1 : index)).filter((i) => i !== -1); | ||
| invalidIndexes.forEach((index) => { | ||
| const env = this.envs.splice(index, 1)[0]; | ||
| this.fire({ old: env, update: undefined }); |
There was a problem hiding this comment.
This is to ensure we fire events for any envs removed from collection.
|
|
||
| public get refreshPromise(): Promise<void> { | ||
| return Promise.all(Array.from(this.refreshPromises.values())).then(); | ||
| public get refreshPromise(): Promise<void> | undefined { |
There was a problem hiding this comment.
We only need to set quickpick as busy if a refresh is going on, so returning undefined is helpful.
| await updateEnvUsingRegistry(resolvedEnv); | ||
| } | ||
| // Display name is not set here as we need version, arch etc. to build it. | ||
| resolvedEnv.display = getEnvDisplayString(resolvedEnv); |
There was a problem hiding this comment.
Allow to show partial display names with the partial info we have.
| */ | ||
| @cache(30_000, true, 10_000) | ||
| // eslint-disable-next-line class-methods-use-this | ||
| private async getInfoCached(command: string): Promise<CondaInfo> { |
There was a problem hiding this comment.
Noticed it was not cached and was being run twice.
| iconPath: getIcon(REFRESH_BUTTON_ICON), | ||
| tooltip: InterpreterQuickPickList.refreshInterpreterList(), | ||
| }, | ||
| callback: () => this.interpreterService.triggerRefresh(), |
There was a problem hiding this comment.
All we need to do is trigger the refresh, the list is automatically updated one by one via change events in the onChanged handler.
|
|
||
| private async setRecommendedItem(items: QuickPickType[], resource: Resource) { | ||
| const interpreterSuggestions = await this.interpreterSelector.getSuggestions(resource); | ||
| if (!this.interpreterService.refreshPromise && interpreterSuggestions.length > 0) { |
There was a problem hiding this comment.
Notice we only set a recommended item only after refresh has finished, otherwise recommended item can change while the list is loading. Let me know if you disagree..
src/client/interpreter/configuration/interpreterSelector/commands/setInterpreter.ts
Outdated
Show resolved
Hide resolved
|
Ping @karthiknadig |
Closes https://github.com/microsoft/vscode-python-internalbacklog/issues/380
Quickpick loads with the sorted list of known environments. If an env gets added to the known list, its added to the end of items list. A lot of effort here is done so that the visible items do not change when the list is loading.