@@ -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 } ;
@@ -679,7 +688,7 @@ export class LaunchpadProvider implements Disposable {
679688 this . container . git . isDiscoveringRepositories ,
680689 this . getEnrichedItems ( { force : options ?. force , cancellation : cancellation } ) ,
681690 options ?. search
682- ? this . getSearchedPullRequests ( options . search )
691+ ? this . getSearchedPullRequests ( options . search , cancellation )
683692 : this . getPullRequestsWithSuggestionCounts ( { force : options ?. force , cancellation : cancellation } ) ,
684693 ] ) ;
685694
@@ -1106,6 +1115,7 @@ function withDurationAndSlowEventOnTimeout<T>(
11061115 promise : Promise < T > ,
11071116 name :
11081117 | 'getPullRequest'
1118+ | 'searchPullRequests'
11091119 | 'getMyPullRequests'
11101120 | 'getCodeSuggestionCounts'
11111121 | 'getCodeSuggestions'
0 commit comments