Skip to content

Commit c333a9c

Browse files
committed
Fixes a message when no issues found
(#3621)
1 parent d408d8e commit c333a9c

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
@@ -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,11 +367,19 @@ 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 {
366-
placeholder: 'All done! Take a vacation',
367-
items: [createDirectiveQuickPickItem(Directive.Cancel, undefined, { label: 'OK' })],
376+
placeholder: 'No issues found. Start work anyway.',
377+
items: [
378+
createQuickPickItemOfT(
379+
state.inWorktree ? 'Create a branch on a worktree' : 'Create a branch',
380+
'start',
381+
),
382+
],
368383
};
369384
}
370385

@@ -376,14 +391,14 @@ export class StartWorkCommand extends QuickCommand<State> {
376391

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

379-
const step = createPickStep({
394+
const step = createPickStep<(typeof items)[0]>({
380395
title: context.title,
381396
placeholder: placeholder,
382397
matchOnDescription: true,
383398
matchOnDetail: true,
384399
items: items,
385400
onDidClickItemButton: (_quickpick, button, { item }) => {
386-
if (button === StartWorkQuickInputButton) {
401+
if (button === StartWorkQuickInputButton && typeof item !== 'string') {
387402
this.startWork(state, item);
388403
return true;
389404
}
@@ -396,7 +411,7 @@ export class StartWorkCommand extends QuickCommand<State> {
396411
return StepResultBreak;
397412
}
398413
const element = selection[0];
399-
return { ...element.item };
414+
return typeof element.item === 'string' ? element.item : { ...element.item };
400415
}
401416

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

0 commit comments

Comments
 (0)