@@ -50,6 +50,7 @@ interface Context {
5050interface State {
5151 item ?: StartWorkItem ;
5252 action ?: StartWorkAction ;
53+ inWorktree ?: boolean ;
5354}
5455
5556export type StartWorkAction = 'start' ;
@@ -123,6 +124,7 @@ export class StartWorkCommand extends QuickCommand<State> {
123124 const result = yield * this . selectCommandStep ( state ) ;
124125 if ( result === StepResultBreak ) continue ;
125126 state . action = result . action ;
127+ state . inWorktree = result . inWorktree ;
126128 }
127129
128130 if ( state . counter < 2 && ! state . action ) {
@@ -149,7 +151,9 @@ export class StartWorkCommand extends QuickCommand<State> {
149151 name : issue ? slug ( `${ issue . id } -${ issue . title } ` ) : undefined ,
150152 suggestNameOnly : true ,
151153 suggestRepoOnly : true ,
154+ flags : state . inWorktree ? [ '--worktree' ] : [ '--switch' ] ,
152155 } ,
156+ confirm : false ,
153157 } ,
154158 this . pickedVia ,
155159 ) ;
@@ -168,14 +172,18 @@ export class StartWorkCommand extends QuickCommand<State> {
168172 return state . counter < 0 ? StepResultBreak : undefined ;
169173 }
170174
171- private * selectCommandStep ( state : StepState < State > ) : StepResultGenerator < { action ?: StartWorkAction } > {
175+ private * selectCommandStep (
176+ state : StepState < State > ,
177+ ) : StepResultGenerator < { action ?: StartWorkAction ; inWorktree ?: boolean } > {
172178 const step = createPickStep ( {
173179 placeholder : 'Start work by creating a new branch' ,
174180 items : [
175181 createQuickPickItemOfT ( 'Create a Branch' , {
176182 action : 'start' ,
177183 } ) ,
184+ createQuickPickItemOfT ( 'Create a Branch in a Worktree' , { action : 'start' , inWorktree : true } ) ,
178185 createQuickPickItemOfT ( 'Create a Branch from an Issue' , { } ) ,
186+ createQuickPickItemOfT ( 'Create a Branch from an Issue in a Worktree' , { inWorktree : true } ) ,
179187 ] ,
180188 } ) ;
181189 const selection : StepSelection < typeof step > = yield step ;
0 commit comments