Skip to content

Commit 6c7362f

Browse files
Reinstate command items when filtering checkout quickpick (fix microsoft#202870) (microsoft#204107)
--------- Co-authored-by: Ladislau Szomoru <3372902+lszomoru@users.noreply.github.com>
1 parent b05778e commit 6c7362f

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

extensions/git/src/commands.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { RemoteSourceAction } from './api/git-base';
2323
abstract class CheckoutCommandItem implements QuickPickItem {
2424
abstract get label(): string;
2525
get description(): string { return ''; }
26-
get alwaysShow(): boolean { return false; }
26+
get alwaysShow(): boolean { return true; }
2727
}
2828

2929
class CreateBranchItem extends CheckoutCommandItem {
@@ -2461,9 +2461,10 @@ export class CommandCenter {
24612461
const createBranchFrom = new CreateBranchFromItem();
24622462
const checkoutDetached = new CheckoutDetachedItem();
24632463
const picks: QuickPickItem[] = [];
2464+
const commands: QuickPickItem[] = [];
24642465

24652466
if (!opts?.detached) {
2466-
picks.push(createBranch, createBranchFrom, checkoutDetached);
2467+
commands.push(createBranch, createBranchFrom, checkoutDetached);
24672468
}
24682469

24692470
const disposables: Disposable[] = [];
@@ -2477,7 +2478,7 @@ export class CommandCenter {
24772478
quickPick.show();
24782479

24792480
picks.push(... await createCheckoutItems(repository, opts?.detached));
2480-
quickPick.items = picks;
2481+
quickPick.items = [...commands, ...picks];
24812482
quickPick.busy = false;
24822483

24832484
const choice = await new Promise<QuickPickItem | undefined>(c => {
@@ -2492,6 +2493,22 @@ export class CommandCenter {
24922493

24932494
c(undefined);
24942495
})));
2496+
disposables.push(quickPick.onDidChangeValue(value => {
2497+
switch (true) {
2498+
case value === '':
2499+
quickPick.items = [...commands, ...picks];
2500+
break;
2501+
case commands.length === 0:
2502+
quickPick.items = picks;
2503+
break;
2504+
case picks.length === 0:
2505+
quickPick.items = commands;
2506+
break;
2507+
default:
2508+
quickPick.items = [...picks, { label: '', kind: QuickPickItemKind.Separator }, ...commands];
2509+
break;
2510+
}
2511+
}));
24952512
});
24962513

24972514
dispose(disposables);

0 commit comments

Comments
 (0)