@@ -327,10 +327,7 @@ public ITask DiscardChanges(GitStatusEntry[] gitStatusEntries)
327327
328328 if ( itemsToRevert . Any ( ) )
329329 {
330- var next = GitClient . Discard ( itemsToRevert ) ;
331- HookupHandlers ( next , true ) ;
332- task . OnEnd -= HookupEndHandlerWithWatcher ;
333- task . Then ( next ) ;
330+ task . Then ( GitClient . Discard ( itemsToRevert ) ) ;
334331 }
335332 }
336333 , ( ) => gitStatusEntries ) ;
@@ -453,35 +450,21 @@ private ITask HookupHandlers(ITask task, bool filesystemChangesExpected)
453450 }
454451 } ;
455452
456- if ( filesystemChangesExpected )
457- task . OnEnd += HookupEndHandlerWithWatcher ;
458- else
459- task . OnEnd += HookupEndHandlerWithoutWatcher ;
460- return task ;
461- }
462-
463- private void HookupEndHandlerWithWatcher ( ITask task , bool success , Exception ex )
464- {
465- HookupEndHandler ( task , true ) ;
466- }
467-
468- private void HookupEndHandlerWithoutWatcher ( ITask task , bool success , Exception ex )
469- {
470- HookupEndHandler ( task , false ) ;
471- }
472-
473- private void HookupEndHandler ( ITask task , bool filesystemChangesExpected )
474- {
475- var isExclusive = task . IsChainExclusive ( ) ;
476- if ( filesystemChangesExpected )
453+ task . Finally ( success =>
477454 {
478- watcher . Start ( ) ;
479- }
455+ if ( filesystemChangesExpected )
456+ {
457+ //Logger.Trace("Ended Operation - Enable Watcher");
458+ watcher . Start ( ) ;
459+ }
480460
481- if ( isExclusive )
482- {
483- IsBusy = false ;
484- }
461+ if ( isExclusive )
462+ {
463+ //Logger.Trace("Ended Operation - Clearing Busy Flag");
464+ IsBusy = false ;
465+ }
466+ } ) ;
467+ return task ;
485468 }
486469
487470 private string GetCurrentHead ( )
0 commit comments