Skip to content

Commit d43bd84

Browse files
authored
python: do not refresh interpreters on quickpick open (#4462)
<!-- Thank you for submitting a pull request. If this is your first pull request you can find information about contributing here: * https://github.com/posit-dev/positron/blob/main/CONTRIBUTING.md We recommend synchronizing your branch with the latest changes in the main branch by either pulling or rebasing. --> <!-- Describe briefly what problem this pull request resolves, or what new feature it introduces. Include screenshots of any new or altered UI. Link to any GitHub issues but avoid "magic" keywords that will automatically close the issue. If there are any details about your approach that are unintuitive or you want to draw attention to, please describe them here. --> related to #3944 Keeps the lists of interpreters the same, rather than refreshing only the first time the Select Interpreter QuickPick is opened which makes it seem like the Positron dropdown is out of sync. This nudges people towards refreshing manually when they have created a new environment, which I believe to be the desired behavior since Positron will not have to continually watch for new envs (which can be expensive, some discussion #2003). I've opened #4269 to track better UI to make refreshing interpreters more obvious. ### QA Notes <!-- Add additional information for QA on how to validate the change, paying special attention to the level of risk, adjacent areas that could be affected by the change, and any important contextual information not present in the linked issues. --> Scenario 1: 1. Open Positron 2. Create new pyenv environment via something like `pyenv virtualenv 3.9.4 test-startup` 3. Check: no new env discovered in Positron dropdown, no new env discovered in `Python: Select Interpreter` 4. Refresh envs using button in `Python: Select Interpreter` 5. See env populate in both locations Scenario 2: 1. Open Positron 2. Create new pyenv environment via something like `pyenv virtualenv 3.9.4 test-startup` 3. Close Positron 4. Open Positron 5. See env populate in both locations
1 parent 616d8fa commit d43bd84

File tree

3 files changed

+35
-6
lines changed

3 files changed

+35
-6
lines changed

extensions/positron-python/src/client/extensionActivation.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ export async function activateComponents(
8787
}
8888
const promises: Promise<ActivationResult>[] = [
8989
// More component activations will go here
90-
pythonEnvironments.activate(components.pythonEnvs, ext),
90+
// --- Start Positron ---
91+
pythonEnvironments.activateAndRefreshEnvs(components.pythonEnvs),
92+
// --- End Positron
9193
];
9294
return Promise.all([legacyActivationResult, ...promises]);
9395
}

extensions/positron-python/src/client/interpreter/configuration/interpreterSelector/commands/setInterpreter.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,19 @@ export class SetInterpreterCommand extends BaseInterpreterSelectorCommand implem
208208
// always trigger a refresh.
209209
if (this.interpreterService.getInterpreters().length === 0) {
210210
this.refreshCallback(quickPick, { showBackButton: params?.showBackButton });
211-
} else {
212-
this.refreshCallback(quickPick, {
213-
ifNotTriggerredAlready: true,
214-
showBackButton: params?.showBackButton,
215-
});
216211
}
212+
// --- Start Positron ---
213+
// Do not trigger a refresh when QuickPick is opened, to keep behavior the same
214+
// between the Quick Pick and the Positron Interpreter Selector
215+
216+
// else {
217+
// this.refreshCallback(quickPick, {
218+
// ifNotTriggerredAlready: true,
219+
// showBackButton: params?.showBackButton,
220+
// });
221+
// }
222+
223+
// --- End Positron ---
217224
},
218225
onChangeItem: {
219226
event: this.interpreterService.onDidChangeInterpreters,

extensions/positron-python/src/client/pythonEnvironments/index.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,26 @@ export async function initialize(ext: ExtensionState): Promise<IDiscoveryAPI> {
5959
return api;
6060
}
6161

62+
// --- Start Positron ---
63+
/**
64+
* Make use of the component (e.g. register with VS Code).
65+
*/
66+
export async function activateAndRefreshEnvs(api: IDiscoveryAPI): Promise<ActivationResult> {
67+
/**
68+
* Force a background refresh of the environments for each extension activation
69+
*
70+
* Based off activate(), but not including the logic around triggering only if
71+
* it has not previously been triggered
72+
*/
73+
74+
api.triggerRefresh().ignoreErrors();
75+
76+
return {
77+
fullyReady: Promise.resolve(),
78+
};
79+
}
80+
// --- End Positron ---
81+
6282
/**
6383
* Make use of the component (e.g. register with VS Code).
6484
*/

0 commit comments

Comments
 (0)