Skip to content

Commit

Permalink
Reinstate command items when filtering checkout quickpick (fix #202870)…
Browse files Browse the repository at this point in the history
… (#204107)

---------

Co-authored-by: Ladislau Szomoru <3372902+lszomoru@users.noreply.github.com>
  • Loading branch information
gjsjohnmurray and lszomoru authored Feb 7, 2024
1 parent b05778e commit 6c7362f
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions extensions/git/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { RemoteSourceAction } from './api/git-base';
abstract class CheckoutCommandItem implements QuickPickItem {
abstract get label(): string;
get description(): string { return ''; }
get alwaysShow(): boolean { return false; }
get alwaysShow(): boolean { return true; }
}

class CreateBranchItem extends CheckoutCommandItem {
Expand Down Expand Up @@ -2461,9 +2461,10 @@ export class CommandCenter {
const createBranchFrom = new CreateBranchFromItem();
const checkoutDetached = new CheckoutDetachedItem();
const picks: QuickPickItem[] = [];
const commands: QuickPickItem[] = [];

if (!opts?.detached) {
picks.push(createBranch, createBranchFrom, checkoutDetached);
commands.push(createBranch, createBranchFrom, checkoutDetached);
}

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

picks.push(... await createCheckoutItems(repository, opts?.detached));
quickPick.items = picks;
quickPick.items = [...commands, ...picks];
quickPick.busy = false;

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

c(undefined);
})));
disposables.push(quickPick.onDidChangeValue(value => {
switch (true) {
case value === '':
quickPick.items = [...commands, ...picks];
break;
case commands.length === 0:
quickPick.items = picks;
break;
case picks.length === 0:
quickPick.items = commands;
break;
default:
quickPick.items = [...picks, { label: '', kind: QuickPickItemKind.Separator }, ...commands];
break;
}
}));
});

dispose(disposables);
Expand Down

0 comments on commit 6c7362f

Please sign in to comment.