mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
fix for issue 4596 (#4670)
This commit is contained in:
@@ -558,14 +558,7 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
|
||||
if (searchTexts && searchTexts.length > 0) {
|
||||
searchTexts.forEach(searchText => {
|
||||
if (searchText !== '@allmarketplace') {
|
||||
filteredExtensions = filteredExtensions.filter(
|
||||
e => e.extensionName && e.extensionName.includes(searchText) ||
|
||||
e.publisher && e.publisher.publisherName && e.publisher.publisherName.includes(searchText) ||
|
||||
e.publisher && e.publisher.displayName && e.publisher.displayName.includes(searchText) ||
|
||||
e.displayName && e.displayName.includes(searchText) ||
|
||||
e.shortDescription && e.shortDescription.includes(searchText) ||
|
||||
e.extensionId && e.extensionId.includes(searchText)
|
||||
);
|
||||
filteredExtensions = filteredExtensions.filter(e => ExtensionGalleryService.isMatchingExtension(e, searchText));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -574,11 +567,11 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
|
||||
// Sorting
|
||||
switch (query.sortBy) {
|
||||
case SortBy.PublisherName:
|
||||
filteredExtensions.sort( (a, b) => ExtensionGalleryService.compareByField(a.publisher, b.publisher, 'publisherName'));
|
||||
filteredExtensions.sort((a, b) => ExtensionGalleryService.compareByField(a.publisher, b.publisher, 'publisherName'));
|
||||
break;
|
||||
case SortBy.Title:
|
||||
default:
|
||||
filteredExtensions.sort( (a, b) => ExtensionGalleryService.compareByField(a, b, 'displayName'));
|
||||
filteredExtensions.sort((a, b) => ExtensionGalleryService.compareByField(a, b, 'displayName'));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -592,6 +585,24 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
|
||||
return { galleryExtensions: filteredExtensions, total: actualTotal };
|
||||
}
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
/*
|
||||
* Checks whether the extension matches the search text
|
||||
*/
|
||||
public static isMatchingExtension(extension: IRawGalleryExtension, searchText: string): boolean {
|
||||
if (!searchText) {
|
||||
return true;
|
||||
}
|
||||
let text = searchText.toLocaleLowerCase();
|
||||
return extension
|
||||
&& (extension.extensionName && extension.extensionName.toLocaleLowerCase().includes(text) ||
|
||||
extension.publisher && extension.publisher.publisherName && extension.publisher.publisherName.toLocaleLowerCase().includes(text) ||
|
||||
extension.publisher && extension.publisher.displayName && extension.publisher.displayName.toLocaleLowerCase().includes(text) ||
|
||||
extension.displayName && extension.displayName.toLocaleLowerCase().includes(text) ||
|
||||
extension.shortDescription && extension.shortDescription.toLocaleLowerCase().includes(text) ||
|
||||
extension.extensionId && extension.extensionId.toLocaleLowerCase().includes(text));
|
||||
}
|
||||
|
||||
public static compareByField(a: any, b: any, fieldName: string): number {
|
||||
if (a && !b) {
|
||||
return 1;
|
||||
@@ -608,7 +619,7 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
|
||||
if (!b || !b[fieldName] && (!a || !a[fieldName])) {
|
||||
return 0;
|
||||
}
|
||||
if (a[fieldName] === b[fieldName]) {
|
||||
if (a[fieldName] === b[fieldName]) {
|
||||
return 0;
|
||||
}
|
||||
return a[fieldName] < b[fieldName] ? -1 : 1;
|
||||
|
||||
Reference in New Issue
Block a user