Skip to content

Commit 4855013

Browse files
author
Benjamin Pasero
committed
Quick open: Once "file results" are loaded, it resets selected file to the first (fix microsoft#102480)
1 parent cb31fc6 commit 4855013

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

src/vs/platform/quickinput/browser/pickerQuickAccess.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ export type Pick<T> = T | IQuickPickSeparator;
7676
export type PicksWithActive<T> = { items: ReadonlyArray<Pick<T>>, active?: T };
7777
export type Picks<T> = ReadonlyArray<Pick<T>> | PicksWithActive<T>;
7878
export type FastAndSlowPicks<T> = { picks: Picks<T>, additionalPicks: Promise<Picks<T>> };
79-
export type FastAndSlowPicksWithActive<T> = { picks: PicksWithActive<T>, additionalPicks: PicksWithActive<Picks<T>> };
8079

8180
function isPicksWithActive<T>(obj: unknown): obj is PicksWithActive<T> {
8281
const candidate = obj as PicksWithActive<T>;
@@ -211,9 +210,23 @@ export abstract class PickerQuickAccessProvider<T extends IPickerQuickAccessItem
211210
}
212211

213212
if (additionalPicks.length > 0 || !fastPicksApplied) {
213+
// If we do not have any activePick or additionalActivePick
214+
// we try to preserve the currently active pick from the
215+
// fast results. This fixes an issue where the user might
216+
// have made a pick active before the additional results
217+
// kick in.
218+
// See https://github.com/microsoft/vscode/issues/102480
219+
let fallbackActivePick: Pick<T> | undefined = undefined;
220+
if (!activePick && !additionalActivePick) {
221+
const fallbackActivePickCandidate = picker.activeItems[0];
222+
if (fallbackActivePickCandidate && picks.includes(fallbackActivePickCandidate)) {
223+
fallbackActivePick = fallbackActivePickCandidate;
224+
}
225+
}
226+
214227
applyPicks({
215228
items: [...picks, ...additionalPicks],
216-
active: activePick || additionalActivePick
229+
active: activePick || additionalActivePick || fallbackActivePick
217230
});
218231
}
219232
} finally {

0 commit comments

Comments
 (0)