Skip to content

Add support for dynamic updates in interpreter list#17043

Merged
karrtikr merged 19 commits intomicrosoft:mainfrom
karrtikr:improveinterpreterdisplay
Sep 21, 2021
Merged

Add support for dynamic updates in interpreter list#17043
karrtikr merged 19 commits intomicrosoft:mainfrom
karrtikr:improveinterpreterdisplay

Conversation

@karrtikr
Copy link

@karrtikr karrtikr commented Aug 20, 2021

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.

@karrtikr karrtikr force-pushed the improveinterpreterdisplay branch 3 times, most recently from 07c95c5 to d1c9d31 Compare August 23, 2021 21:45
@karrtikr karrtikr added this to the September 2021 milestone Sep 1, 2021
@karrtikr karrtikr force-pushed the improveinterpreterdisplay branch 2 times, most recently from a8485cb to c38f2b0 Compare September 9, 2021 19:26
@karrtikr karrtikr force-pushed the improveinterpreterdisplay branch from 2093a8f to 0e5dece Compare September 15, 2021 23:16
@karrtikr karrtikr marked this pull request as ready for review September 16, 2021 23:12
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 });
Copy link
Author

@karrtikr karrtikr Sep 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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> {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed it was not cached and was being run twice.

iconPath: getIcon(REFRESH_BUTTON_ICON),
tooltip: InterpreterQuickPickList.refreshInterpreterList(),
},
callback: () => this.interpreterService.triggerRefresh(),
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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..

@karrtikr
Copy link
Author

Ping @karthiknadig

Copy link
Member

@karthiknadig karthiknadig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!!!

@karrtikr karrtikr merged commit ec62819 into microsoft:main Sep 21, 2021
@karrtikr karrtikr deleted the improveinterpreterdisplay branch September 21, 2021 23:19
@karrtikr karrtikr added the on-testplan Added to test plan label Sep 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

on-testplan Added to test plan

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants