diff --git a/src/plus/startWork/startWork.ts b/src/plus/startWork/startWork.ts index 44ab1f64d9588..51d3f5b5a5810 100644 --- a/src/plus/startWork/startWork.ts +++ b/src/plus/startWork/startWork.ts @@ -55,6 +55,7 @@ interface Context { interface State { item?: StartWorkItem; action?: StartWorkAction; + inWorktree?: boolean; } type StartWorkStepState = RequireSome, 'item'>; @@ -136,6 +137,7 @@ export class StartWorkCommand extends QuickCommand { const result = yield* this.selectCommandStep(state); if (result === StepResultBreak) continue; state.action = result.action; + state.inWorktree = result.inWorktree; await updateContextItems(this.container, context); @@ -162,7 +164,9 @@ export class StartWorkCommand extends QuickCommand { name: issue ? slug(`${issue.id}-${issue.title}`) : undefined, suggestNameOnly: true, suggestRepoOnly: true, + flags: state.inWorktree ? ['--worktree'] : ['--switch'], }, + confirm: false, }, this.pickedVia, ); @@ -176,14 +180,18 @@ export class StartWorkCommand extends QuickCommand { return state.counter < 0 ? StepResultBreak : undefined; } - private *selectCommandStep(state: StepState): StepResultGenerator<{ action?: StartWorkAction }> { + private *selectCommandStep( + state: StepState, + ): StepResultGenerator<{ action?: StartWorkAction; inWorktree?: boolean }> { const step = createPickStep({ placeholder: 'Start work by creating a new branch', items: [ createQuickPickItemOfT('Create a branch', { action: 'start', }), + createQuickPickItemOfT('Create a branch on a worktree', { action: 'start', inWorktree: true }), createQuickPickItemOfT('Create a branch from an issue', {}), + createQuickPickItemOfT('Create a branch from an issue on a worktree', { inWorktree: true }), ], }); const selection: StepSelection = yield step;