@@ -91,7 +91,7 @@ export interface ExtensionsListViewOptions {
91
91
92
92
interface IQueryResult {
93
93
model : IPagedModel < IExtension > ;
94
- description ?: string ;
94
+ message ?: { text : string ; severity : Severity } ;
95
95
readonly onDidChangeModel ?: Event < IPagedModel < IExtension > > ;
96
96
readonly disposables : DisposableStore ;
97
97
}
@@ -248,7 +248,7 @@ export class ExtensionsListView extends ViewPane {
248
248
try {
249
249
this . queryResult = await this . query ( parsedQuery , options , token ) ;
250
250
const model = this . queryResult . model ;
251
- this . setModel ( model , this . queryResult . description ? { text : this . queryResult . description , severity : Severity . Info } : undefined ) ;
251
+ this . setModel ( model , this . queryResult . message ) ;
252
252
if ( this . queryResult . onDidChangeModel ) {
253
253
this . queryResult . disposables . add ( this . queryResult . onDidChangeModel ( model => {
254
254
if ( this . queryResult ) {
@@ -310,8 +310,7 @@ export class ExtensionsListView extends ViewPane {
310
310
}
311
311
312
312
const galleryQueryOptions : IGalleryQueryOptions = { ...options , sortBy : isLocalSortBy ( options . sortBy ) ? undefined : options . sortBy } ;
313
- const model = await this . queryGallery ( query , galleryQueryOptions , token ) ;
314
- return { model, disposables : new DisposableStore ( ) } ;
313
+ return this . queryGallery ( query , galleryQueryOptions , token ) ;
315
314
}
316
315
317
316
private async queryByIds ( ids : string [ ] , options : IQueryOptions , token : CancellationToken ) : Promise < IPagedModel < IExtension > > {
@@ -356,7 +355,7 @@ export class ExtensionsListView extends ViewPane {
356
355
357
356
return {
358
357
model : new PagedModel ( extensions ) ,
359
- description,
358
+ message : description ? { text : description , severity : Severity . Info } : undefined ,
360
359
onDidChangeModel : onDidChangeModel . event ,
361
360
disposables
362
361
} ;
@@ -720,45 +719,66 @@ export class ExtensionsListView extends ViewPane {
720
719
return hasChanged ? extensions : undefined ;
721
720
}
722
721
723
- private async queryGallery ( query : Query , options : IGalleryQueryOptions , token : CancellationToken ) : Promise < IPagedModel < IExtension > > {
722
+ private async queryGallery ( query : Query , options : IGalleryQueryOptions , token : CancellationToken ) : Promise < IQueryResult > {
724
723
const hasUserDefinedSortOrder = options . sortBy !== undefined ;
725
724
if ( ! hasUserDefinedSortOrder && ! query . value . trim ( ) ) {
726
725
options . sortBy = GallerySortBy . InstallCount ;
727
726
}
728
727
729
728
if ( this . isRecommendationsQuery ( query ) ) {
730
- return this . queryRecommendations ( query , options , token ) ;
729
+ const model = await this . queryRecommendations ( query , options , token ) ;
730
+ return { model, disposables : new DisposableStore ( ) } ;
731
731
}
732
732
733
733
const text = query . value ;
734
734
735
735
if ( ! text ) {
736
736
options . source = 'viewlet' ;
737
737
const pager = await this . extensionsWorkbenchService . queryGallery ( options , token ) ;
738
- return new PagedModel ( pager ) ;
738
+ return { model : new PagedModel ( pager ) , disposables : new DisposableStore ( ) } ;
739
739
}
740
740
741
741
if ( / \b e x t : ( [ ^ \s ] + ) \b / g. test ( text ) ) {
742
742
options . text = text ;
743
743
options . source = 'file-extension-tags' ;
744
744
const pager = await this . extensionsWorkbenchService . queryGallery ( options , token ) ;
745
- return new PagedModel ( pager ) ;
745
+ return { model : new PagedModel ( pager ) , disposables : new DisposableStore ( ) } ;
746
746
}
747
747
748
748
options . text = text . substring ( 0 , 350 ) ;
749
749
options . source = 'searchText' ;
750
750
751
751
if ( hasUserDefinedSortOrder || / \b ( c a t e g o r y | t a g ) : ( [ ^ \s ] + ) \b / gi. test ( text ) || / \b f e a t u r e d ( \s + | \b | $ ) / gi. test ( text ) ) {
752
752
const pager = await this . extensionsWorkbenchService . queryGallery ( options , token ) ;
753
- return new PagedModel ( pager ) ;
753
+ return { model : new PagedModel ( pager ) , disposables : new DisposableStore ( ) } ;
754
754
}
755
755
756
- const [ pager , preferredExtensions ] = await Promise . all ( [
757
- this . extensionsWorkbenchService . queryGallery ( options , token ) ,
758
- this . getPreferredExtensions ( options . text . toLowerCase ( ) , token ) . catch ( ( ) => [ ] )
759
- ] ) ;
756
+ try {
757
+ const [ pager , preferredExtensions ] = await Promise . all ( [
758
+ this . extensionsWorkbenchService . queryGallery ( options , token ) ,
759
+ this . getPreferredExtensions ( options . text . toLowerCase ( ) , token ) . catch ( ( ) => [ ] )
760
+ ] ) ;
761
+
762
+ const model = preferredExtensions . length ? new PreferredExtensionsPagedModel ( preferredExtensions , pager ) : new PagedModel ( pager ) ;
763
+ return { model, disposables : new DisposableStore ( ) } ;
764
+ } catch ( error ) {
765
+ if ( isCancellationError ( error ) ) {
766
+ throw error ;
767
+ }
760
768
761
- return preferredExtensions . length ? new PreferredExtensionsPagedModel ( preferredExtensions , pager ) : new PagedModel ( pager ) ;
769
+ if ( ! ( error instanceof ExtensionGalleryError ) ) {
770
+ throw error ;
771
+ }
772
+
773
+ const searchText = options . text . toLowerCase ( ) ;
774
+ const localExtensions = this . extensionsWorkbenchService . local . filter ( e => ! e . isBuiltin && ( e . name . toLowerCase ( ) . indexOf ( searchText ) > - 1 || e . displayName . toLowerCase ( ) . indexOf ( searchText ) > - 1 || e . description . toLowerCase ( ) . indexOf ( searchText ) > - 1 ) ) ;
775
+ if ( localExtensions . length ) {
776
+ const message = this . getMessage ( error ) ;
777
+ return { model : new PagedModel ( localExtensions ) , disposables : new DisposableStore ( ) , message : { text : localize ( 'showing local extensions only' , "{0} Showing local extensions." , message . text ) , severity : message . severity } } ;
778
+ }
779
+
780
+ throw error ;
781
+ }
762
782
}
763
783
764
784
private async getPreferredExtensions ( searchText : string , token : CancellationToken ) : Promise < IExtension [ ] > {
0 commit comments