@@ -559,6 +559,17 @@ export class LaunchpadCommand extends QuickCommand<State> {
559559 LaunchpadSettingsQuickInputButton ,
560560 RefreshQuickInputButton ,
561561 ] ,
562+
563+ onDidChangeActive : quickpick => {
564+ const hasActiveLaunchpadItems = quickpick . activeItems . find ( i => 'item' in i ) ;
565+ if ( hasActiveLaunchpadItems ) {
566+ this . updateItemsDebouncer . cancel ( ) ;
567+ return true ;
568+ }
569+
570+ return false ;
571+ } ,
572+
562573 onDidChangeValue : async quickpick => {
563574 const { value } = quickpick ;
564575 const hideGroups = Boolean ( value ?. length ) ;
@@ -614,15 +625,15 @@ export class LaunchpadCommand extends QuickCommand<State> {
614625 }
615626 }
616627
617- // wait a little bit because the active quickpick is updated with some delay
618- await new Promise ( resolve => setTimeout ( resolve , 100 ) ) ;
619- const hasActiveLaunchpadItems = quickpick . activeItems . find ( i => 'item' in i ) ;
620- if ( hasActiveLaunchpadItems ) {
621- // We have an active item, so we can exit now without sending any requests to API
622- this . updateItemsDebouncer . cancel ( ) ;
623- return true ;
624- }
625-
628+ // Here we cannot check for active items, because they are not yet updated after the last search value.
629+ // So, we immediately init updating process, without a condition.
630+ // But it's delayed by a debouncer.
631+ //
632+ // Right after the `onDidChangeValue` it goes to `onDidChangeActive`, where active items are already updated.
633+ // It happens very soon much after that the delay of the debouncer.
634+ //
635+ // If it occurs that the quickpic has an active item, it cancells the update operation,
636+ // it happens before the update procedure starts executing.
626637 await updateItems ( quickpick ) ;
627638 return true ;
628639 } ,
0 commit comments