@@ -55,6 +55,7 @@ interface Context {
5555interface State {
5656 item ?: StartWorkItem ;
5757 action ?: StartWorkAction ;
58+ inWorktree ?: boolean ;
5859}
5960
6061export type StartWorkAction = 'start' ;
@@ -128,6 +129,7 @@ export class StartWorkCommand extends QuickCommand<State> {
128129 const result = yield * this . selectCommandStep ( state ) ;
129130 if ( result === StepResultBreak ) continue ;
130131 state . action = result . action ;
132+ state . inWorktree = result . inWorktree ;
131133 }
132134
133135 if ( state . counter < 2 && ! state . action ) {
@@ -154,7 +156,9 @@ export class StartWorkCommand extends QuickCommand<State> {
154156 name : issue ? slug ( `${ issue . id } -${ issue . title } ` ) : undefined ,
155157 suggestNameOnly : true ,
156158 suggestRepoOnly : true ,
159+ flags : state . inWorktree ? [ '--worktree' ] : [ '--switch' ] ,
157160 } ,
161+ confirm : false ,
158162 } ,
159163 this . pickedVia ,
160164 ) ;
@@ -173,14 +177,18 @@ export class StartWorkCommand extends QuickCommand<State> {
173177 return state . counter < 0 ? StepResultBreak : undefined ;
174178 }
175179
176- private * selectCommandStep ( state : StepState < State > ) : StepResultGenerator < { action ?: StartWorkAction } > {
180+ private * selectCommandStep (
181+ state : StepState < State > ,
182+ ) : StepResultGenerator < { action ?: StartWorkAction ; inWorktree ?: boolean } > {
177183 const step = createPickStep ( {
178184 placeholder : 'Start work by creating a new branch' ,
179185 items : [
180186 createQuickPickItemOfT ( 'Create a branch' , {
181187 action : 'start' ,
182188 } ) ,
189+ createQuickPickItemOfT ( 'Create a branch on a worktree' , { action : 'start' , inWorktree : true } ) ,
183190 createQuickPickItemOfT ( 'Create a branch from an issue' , { } ) ,
191+ createQuickPickItemOfT ( 'Create a branch from an issue on a worktree' , { inWorktree : true } ) ,
184192 ] ,
185193 } ) ;
186194 const selection : StepSelection < typeof step > = yield step ;
0 commit comments