Skip to content

Commit b9533fe

Browse files
committed
Fixes a message when no issues found
(#3621, #3698)
1 parent 38f7ee0 commit b9533fe

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

src/plus/startWork/startWork.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,12 @@ export class StartWorkCommand extends QuickCommand<State> {
131131
await updateContextItems(this.container, context);
132132
const result = yield* this.pickIssueStep(state, context);
133133
if (result === StepResultBreak) continue;
134-
state.item = result;
135-
state.action = 'start';
134+
if (typeof result !== 'string') {
135+
state.item = result;
136+
state.action = 'start';
137+
} else {
138+
state.action = result;
139+
}
136140
}
137141

138142
const issue = state.item?.item?.issue;
@@ -315,7 +319,10 @@ export class StartWorkCommand extends QuickCommand<State> {
315319
return StepResultBreak;
316320
}
317321

318-
private *pickIssueStep(state: StepState<State>, context: Context): StepResultGenerator<StartWorkItem> {
322+
private *pickIssueStep(
323+
state: StepState<State>,
324+
context: Context,
325+
): StepResultGenerator<StartWorkItem | StartWorkAction> {
319326
const buildIssueItem = (i: StartWorkItem) => {
320327
return {
321328
label:
@@ -341,11 +348,19 @@ export class StartWorkCommand extends QuickCommand<State> {
341348
return items;
342349
};
343350

344-
function getItemsAndPlaceholder() {
351+
function getItemsAndPlaceholder(): {
352+
placeholder: string;
353+
items: QuickPickItemOfT<StartWorkItem | StartWorkAction>[];
354+
} {
345355
if (!context.result.items.length) {
346356
return {
347-
placeholder: 'All done! Take a vacation',
348-
items: [createDirectiveQuickPickItem(Directive.Cancel, undefined, { label: 'OK' })],
357+
placeholder: 'No issues found. Start work anyway.',
358+
items: [
359+
createQuickPickItemOfT(
360+
state.inWorktree ? 'Create a branch on a worktree' : 'Create a branch',
361+
'start',
362+
),
363+
],
349364
};
350365
}
351366

@@ -357,7 +372,7 @@ export class StartWorkCommand extends QuickCommand<State> {
357372

358373
const { items, placeholder } = getItemsAndPlaceholder();
359374

360-
const step = createPickStep({
375+
const step = createPickStep<(typeof items)[0]>({
361376
title: context.title,
362377
placeholder: placeholder,
363378
matchOnDescription: true,
@@ -370,7 +385,7 @@ export class StartWorkCommand extends QuickCommand<State> {
370385
return StepResultBreak;
371386
}
372387
const element = selection[0];
373-
return { ...element.item };
388+
return typeof element.item === 'string' ? element.item : { ...element.item };
374389
}
375390

376391
private startWork(state: PartialStepState<State>, item?: StartWorkItem) {

0 commit comments

Comments
 (0)