@@ -320,33 +320,42 @@ export class LaunchpadProvider implements Disposable {
320320 return { prs : prs , suggestionCounts : suggestionCounts } ;
321321 }
322322
323- private async getSearchedPullRequests ( search : string ) {
323+ private async getSearchedPullRequests ( search : string , cancellation ?: CancellationToken ) {
324324 // TODO: This needs to be generalized to work outside of GitHub,
325325 // The current idea is that we should iterate the connected integrations and apply their parsing.
326326 // Probably we even want to build a map like this: { integrationId: identity }
327327 // Then we iterate connected integrations and search in each of them with the corresponding identity.
328328 const { ownerAndRepo, prNumber } = getPullRequestIdentityValuesFromSearch ( search ) ;
329329 let result : TimedResult < SearchedPullRequest [ ] | undefined > | undefined ;
330330
331- if ( prNumber != null ) {
332- if ( ownerAndRepo != null ) {
333- // TODO: This needs to be generalized to work outside of GitHub
334- const integration = await this . container . integrations . get ( HostingIntegrationId . GitHub ) ;
335- const [ owner , repo ] = ownerAndRepo . split ( '/' , 2 ) ;
336- const descriptor : GitHubRepositoryDescriptor = {
337- key : ownerAndRepo ,
338- owner : owner ,
339- name : repo ,
340- } ;
341- const pr = await withDurationAndSlowEventOnTimeout (
342- integration ?. getPullRequest ( descriptor , prNumber ) ,
343- 'getPullRequest' ,
344- this . container ,
345- ) ;
346- if ( pr ?. value != null ) {
347- result = { value : [ { pullRequest : pr . value , reasons : [ ] } ] , duration : pr . duration } ;
348- return { prs : result , suggestionCounts : undefined } ;
349- }
331+ if ( prNumber != null && ownerAndRepo != null ) {
332+ // TODO: This needs to be generalized to work outside of GitHub
333+ const integration = await this . container . integrations . get ( HostingIntegrationId . GitHub ) ;
334+ const [ owner , repo ] = ownerAndRepo . split ( '/' , 2 ) ;
335+ const descriptor : GitHubRepositoryDescriptor = {
336+ key : ownerAndRepo ,
337+ owner : owner ,
338+ name : repo ,
339+ } ;
340+ const pr = await withDurationAndSlowEventOnTimeout (
341+ integration ?. getPullRequest ( descriptor , prNumber ) ,
342+ 'getPullRequest' ,
343+ this . container ,
344+ ) ;
345+ if ( pr ?. value != null ) {
346+ result = { value : [ { pullRequest : pr . value , reasons : [ ] } ] , duration : pr . duration } ;
347+ return { prs : result , suggestionCounts : undefined } ;
348+ }
349+ } else {
350+ const integration = await this . container . integrations . get ( HostingIntegrationId . GitHub ) ;
351+ const prs = await withDurationAndSlowEventOnTimeout (
352+ integration ?. searchPullRequests ( search , undefined , cancellation ) ,
353+ 'searchPullRequests' ,
354+ this . container ,
355+ ) ;
356+ if ( prs != null ) {
357+ result = { value : prs . value ?. map ( pr => ( { pullRequest : pr , reasons : [ ] } ) ) , duration : prs . duration } ;
358+ return { prs : result , suggestionCounts : undefined } ;
350359 }
351360 }
352361 return { prs : undefined , suggestionCounts : undefined } ;
@@ -673,7 +682,7 @@ export class LaunchpadProvider implements Disposable {
673682 this . container . git . isDiscoveringRepositories ,
674683 this . getEnrichedItems ( { force : options ?. force , cancellation : cancellation } ) ,
675684 options ?. search
676- ? this . getSearchedPullRequests ( options . search )
685+ ? this . getSearchedPullRequests ( options . search , cancellation )
677686 : this . getPullRequestsWithSuggestionCounts ( { force : options ?. force , cancellation : cancellation } ) ,
678687 ] ) ;
679688
@@ -1086,6 +1095,7 @@ function withDurationAndSlowEventOnTimeout<T>(
10861095 promise : Promise < T > ,
10871096 name :
10881097 | 'getPullRequest'
1098+ | 'searchPullRequests'
10891099 | 'getMyPullRequests'
10901100 | 'getCodeSuggestionCounts'
10911101 | 'getCodeSuggestions'
0 commit comments