@@ -24,7 +24,7 @@ import type { SearchedIssue } from '../../git/models/issue';
2424import type { QuickPickItemOfT } from '../../quickpicks/items/common' ;
2525import { createQuickPickItemOfT , createQuickPickSeparator } from '../../quickpicks/items/common' ;
2626import type { DirectiveQuickPickItem } from '../../quickpicks/items/directive' ;
27- import { createDirectiveQuickPickItem , Directive } from '../../quickpicks/items/directive' ;
27+ import { createDirectiveQuickPickItem , Directive , isDirectiveQuickPickItem } from '../../quickpicks/items/directive' ;
2828import { fromNow } from '../../system/date' ;
2929
3030export type StartWorkItem = {
@@ -99,17 +99,19 @@ export class StartWorkCommand extends QuickCommand<State> {
9999
100100 assertsStartWorkStepState ( state ) ;
101101
102- if ( this . confirm ( state . confirm ) ) {
102+ if ( state . action == null && this . confirm ( state . confirm ) ) {
103103 const result = yield * this . confirmStep ( state , context ) ;
104- if ( result === StepResultBreak ) continue ;
104+ if ( result === StepResultBreak ) {
105+ state . item = undefined ! ;
106+ continue ;
107+ }
105108
106109 state . action = result ;
107110 }
108111
109112 if ( typeof state . action === 'string' ) {
110113 switch ( state . action ) {
111114 case 'start' :
112- //yield* this.startWorkCommandSteps(state.item.item);
113115 yield * getSteps (
114116 this . container ,
115117 {
@@ -119,7 +121,6 @@ export class StartWorkCommand extends QuickCommand<State> {
119121 repo : undefined ,
120122 name : `${ state . item . item . issue . id } -${ state . item . item . issue . title } ` ,
121123 suggestNameOnly : true ,
122- //flags: ['--switch'],
123124 } ,
124125 } ,
125126 this . pickedVia ,
@@ -186,8 +187,10 @@ export class StartWorkCommand extends QuickCommand<State> {
186187 items : items ,
187188 onDidClickItemButton : ( _quickpick , button , { item } ) => {
188189 if ( button === StartWorkQuickInputButton ) {
189- startWork ( item . item ) ;
190+ this . startWork ( state , item ) ;
191+ return true ;
190192 }
193+ return false ;
191194 } ,
192195 } ) ;
193196
@@ -239,16 +242,25 @@ export class StartWorkCommand extends QuickCommand<State> {
239242 onDidClickItemButton : ( _quickpick , button , _item ) => {
240243 switch ( button ) {
241244 case StartWorkQuickInputButton :
242- startWork ( state . item . item ) ;
243- break ;
245+ if ( isDirectiveQuickPickItem ( _item ) ) return ;
246+ this . startWork ( state ) ;
247+ return true ;
244248 }
249+ return false ;
245250 } ,
246251 } ,
247252 ) ;
248253
249254 const selection : StepSelection < typeof step > = yield step ;
250255 return canPickStepContinue ( step , state , selection ) ? selection [ 0 ] . item : StepResultBreak ;
251256 }
257+
258+ private startWork ( state : PartialStepState < State > , item ?: StartWorkItem ) {
259+ state . action = 'start' ;
260+ if ( item != null ) {
261+ state . item = item ;
262+ }
263+ }
252264}
253265
254266async function updateContextItems ( container : Container , context : Context ) {
@@ -259,7 +271,3 @@ async function updateContextItems(container: Container, context: Context) {
259271 } ) ) ?? [ ] ,
260272 } ;
261273}
262-
263- function startWork ( _issue : SearchedIssue ) {
264- // TODO: Hack here
265- }
0 commit comments