@@ -574,38 +574,43 @@ export class LaunchpadCommand extends QuickCommand<State> {
574574 quickpick . items = [ ...quickpick . items ] ;
575575 }
576576
577- if ( value ?. length && ! activeLaunchpadItems . length ) {
578- const prUrlIdentity = getPullRequestIdentityValuesFromSearch ( value ) ;
579- if ( prUrlIdentity . prNumber != null ) {
580- const launchpadItems = quickpick . items . filter (
581- ( i ) : i is LaunchpadItemQuickPickItem => 'item' in i ,
582- ) ;
583- let item = launchpadItems . find ( i =>
584- // perform strict match first
585- doesPullRequestSatisfyGitHubRepositoryURLIdentity ( i . item , prUrlIdentity ) ,
586- ) ;
587- if ( item == null ) {
588- // Haven't found full match, so let's at least find something with the same pr number
589- item = launchpadItems . find ( i => i . item . id === prUrlIdentity . prNumber ) ;
590- }
591- if ( item != null ) {
592- if ( ! item . alwaysShow ) {
593- item . alwaysShow = true ;
594- // Force quickpick to update by changing the items object:
595- quickpick . items = [ ...quickpick . items ] ;
596- }
597- // We have found an item that matches to the URL.
598- // Now it will be displayed as the found item and we exit this function now without sending any requests to API:
599- this . updateItemsDebouncer . cancel ( ) ;
600- return true ;
601- }
602- // Nothing is found above, so let's perform search in the API:
603- await updateItems ( quickpick , value ) ;
604- quickpick . items = quickpick . items . filter ( ( i ) : i is LaunchpadItemQuickPickItem => 'item' in i ) ;
605- groupsHidden = true ;
577+ if ( ! value ?. length || activeLaunchpadItems . length ) {
578+ // Nothing to search or use items that have been found locally
579+ this . updateItemsDebouncer . cancel ( ) ;
580+ return true ;
581+ }
582+
583+ const prUrlIdentity = getPullRequestIdentityValuesFromSearch ( value ) ;
584+ if ( prUrlIdentity . prNumber == null ) {
585+ // Not a valid PR URL
586+ this . updateItemsDebouncer . cancel ( ) ;
587+ return true ;
588+ }
589+
590+ const launchpadItems = quickpick . items . filter ( ( i ) : i is LaunchpadItemQuickPickItem => 'item' in i ) ;
591+ let item = launchpadItems . find ( i =>
592+ // perform strict match first
593+ doesPullRequestSatisfyGitHubRepositoryURLIdentity ( i . item , prUrlIdentity ) ,
594+ ) ;
595+ if ( item == null ) {
596+ // Haven't found full match, so let's at least find something with the same pr number
597+ item = launchpadItems . find ( i => i . item . id === prUrlIdentity . prNumber ) ;
598+ }
599+ if ( item != null ) {
600+ if ( ! item . alwaysShow ) {
601+ item . alwaysShow = true ;
602+ // Force quickpick to update by changing the items object:
603+ quickpick . items = [ ...quickpick . items ] ;
606604 }
605+ // We have found an item that matches to the URL.
606+ // Now it will be displayed as the found item and we exit this function now without sending any requests to API:
607+ this . updateItemsDebouncer . cancel ( ) ;
608+ return true ;
607609 }
608- this . updateItemsDebouncer . cancel ( ) ;
610+ // Nothing is found above, so let's perform search in the API:
611+ await updateItems ( quickpick , value ) ;
612+ quickpick . items = quickpick . items . filter ( ( i ) : i is LaunchpadItemQuickPickItem => 'item' in i ) ;
613+ groupsHidden = true ;
609614 return true ;
610615 } ,
611616 onDidClickButton : async ( quickpick , button ) => {
0 commit comments