Skip to content

Commit ac890d2

Browse files
committed
fixup! Fixes a message when no issues found
1 parent e835df7 commit ac890d2

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

src/plus/startWork/startWork.ts

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,11 @@ export class StartWorkCommand extends QuickCommand<State> {
144144
if (state.counter < 1 || (state.item == null && !state.action)) {
145145
const result = yield* this.pickIssueStep(state, context);
146146
if (result === StepResultBreak) continue;
147-
state.item = result;
147+
if (typeof result !== 'string') {
148+
state.item = result;
149+
} else {
150+
state.action = result;
151+
}
148152
}
149153

150154
if (state.action == null && this.confirm(state.confirm)) {
@@ -333,7 +337,10 @@ export class StartWorkCommand extends QuickCommand<State> {
333337
return StepResultBreak;
334338
}
335339

336-
private *pickIssueStep(state: StepState<State>, context: Context): StepResultGenerator<StartWorkItem> {
340+
private *pickIssueStep(
341+
state: StepState<State>,
342+
context: Context,
343+
): StepResultGenerator<StartWorkItem | StartWorkAction> {
337344
const buildIssueItem = (i: StartWorkItem) => {
338345
const buttons = [StartWorkQuickInputButton];
339346
return {
@@ -360,12 +367,20 @@ export class StartWorkCommand extends QuickCommand<State> {
360367
return items;
361368
};
362369

363-
function getItemsAndPlaceholder() {
370+
function getItemsAndPlaceholder(): {
371+
placeholder: string;
372+
items: QuickPickItemOfT<StartWorkItem | StartWorkAction>[];
373+
} {
364374
if (!context.result.items.length) {
365375
return {
366376
placeholder: 'No issues found. Start work anyway.',
367377
// TODO: items: [createCallbackQuickPickItem(() => startWork(null), undefined, { label: 'Start Work' })],
368-
items: [createDirectiveQuickPickItem(Directive.Cancel, undefined, { label: 'Start Work' })],
378+
items: [
379+
createQuickPickItemOfT(
380+
state.inWorktree ? 'Create a branch on a worktree' : 'Create a branch',
381+
'start',
382+
),
383+
],
369384
};
370385
}
371386

@@ -377,14 +392,14 @@ export class StartWorkCommand extends QuickCommand<State> {
377392

378393
const { items, placeholder } = getItemsAndPlaceholder();
379394

380-
const step = createPickStep({
395+
const step = createPickStep<(typeof items)[0]>({
381396
title: context.title,
382397
placeholder: placeholder,
383398
matchOnDescription: true,
384399
matchOnDetail: true,
385400
items: items,
386401
onDidClickItemButton: (_quickpick, button, { item }) => {
387-
if (button === StartWorkQuickInputButton) {
402+
if (button === StartWorkQuickInputButton && typeof item !== 'string') {
388403
this.startWork(state, item);
389404
return true;
390405
}
@@ -397,7 +412,7 @@ export class StartWorkCommand extends QuickCommand<State> {
397412
return StepResultBreak;
398413
}
399414
const element = selection[0];
400-
return { ...element.item };
415+
return typeof element.item === 'string' ? element.item : { ...element.item };
401416
}
402417

403418
private *confirmStep(state: StartWorkStepState, _context: Context): StepResultGenerator<StartWorkAction> {

0 commit comments

Comments
 (0)