Skip to content

Commit 9659c19

Browse files
sergeibbbchivorotkiv
authored andcommitted
Fixes a message when no issues found
(#3621)
1 parent c1f3e4e commit 9659c19

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

src/plus/startWork/startWork.ts

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,12 @@ export class StartWorkCommand extends QuickCommand<State> {
136136
await updateContextItems(this.container, context);
137137
const result = yield* this.pickIssueStep(state, context);
138138
if (result === StepResultBreak) continue;
139-
state.item = result;
140-
state.action = 'start';
139+
if (typeof result !== 'string') {
140+
state.item = result;
141+
state.action = 'start';
142+
} else {
143+
state.action = result;
144+
}
141145
}
142146

143147
const issue = state.item?.item?.issue;
@@ -320,7 +324,10 @@ export class StartWorkCommand extends QuickCommand<State> {
320324
return StepResultBreak;
321325
}
322326

323-
private *pickIssueStep(state: StepState<State>, context: Context): StepResultGenerator<StartWorkItem> {
327+
private *pickIssueStep(
328+
state: StepState<State>,
329+
context: Context,
330+
): StepResultGenerator<StartWorkItem | StartWorkAction> {
324331
const buildIssueItem = (i: StartWorkItem) => {
325332
const buttons = [StartWorkQuickInputButton];
326333
return {
@@ -348,11 +355,19 @@ export class StartWorkCommand extends QuickCommand<State> {
348355
return items;
349356
};
350357

351-
function getItemsAndPlaceholder() {
358+
function getItemsAndPlaceholder(): {
359+
placeholder: string;
360+
items: QuickPickItemOfT<StartWorkItem | StartWorkAction>[];
361+
} {
352362
if (!context.result.items.length) {
353363
return {
354-
placeholder: 'All done! Take a vacation',
355-
items: [createDirectiveQuickPickItem(Directive.Cancel, undefined, { label: 'OK' })],
364+
placeholder: 'No issues found. Start work anyway.',
365+
items: [
366+
createQuickPickItemOfT(
367+
state.inWorktree ? 'Create a branch on a worktree' : 'Create a branch',
368+
'start',
369+
),
370+
],
356371
};
357372
}
358373

@@ -364,14 +379,14 @@ export class StartWorkCommand extends QuickCommand<State> {
364379

365380
const { items, placeholder } = getItemsAndPlaceholder();
366381

367-
const step = createPickStep({
382+
const step = createPickStep<(typeof items)[0]>({
368383
title: context.title,
369384
placeholder: placeholder,
370385
matchOnDescription: true,
371386
matchOnDetail: true,
372387
items: items,
373388
onDidClickItemButton: (_quickpick, button, { item }) => {
374-
if (button === StartWorkQuickInputButton) {
389+
if (button === StartWorkQuickInputButton && typeof item !== 'string') {
375390
this.startWork(state, item);
376391
return true;
377392
}
@@ -384,7 +399,7 @@ export class StartWorkCommand extends QuickCommand<State> {
384399
return StepResultBreak;
385400
}
386401
const element = selection[0];
387-
return { ...element.item };
402+
return typeof element.item === 'string' ? element.item : { ...element.item };
388403
}
389404

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

0 commit comments

Comments
 (0)