mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-13 05:01:08 +01:00
Fix #59750
This commit is contained in:
@@ -149,7 +149,8 @@ export interface ITranslation {
|
||||
export interface IExtensionGalleryService {
|
||||
_serviceBrand: any;
|
||||
isEnabled(): boolean;
|
||||
query(options?: IQueryOptions): Promise<IPager<IGalleryExtension>>;
|
||||
query(token: CancellationToken): Promise<IPager<IGalleryExtension>>;
|
||||
query(options: IQueryOptions, token: CancellationToken): Promise<IPager<IGalleryExtension>>;
|
||||
download(extension: IGalleryExtension, operation: InstallOperation): Promise<string>;
|
||||
reportStatistic(publisher: string, name: string, version: string, type: StatisticType): Promise<void>;
|
||||
getReadme(extension: IGalleryExtension, token: CancellationToken): Promise<string>;
|
||||
|
||||
@@ -395,7 +395,12 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
|
||||
});
|
||||
}
|
||||
|
||||
query(options: IQueryOptions = {}): Promise<IPager<IGalleryExtension>> {
|
||||
query(token: CancellationToken): Promise<IPager<IGalleryExtension>>;
|
||||
query(options: IQueryOptions, token: CancellationToken): Promise<IPager<IGalleryExtension>>;
|
||||
query(arg1: any, arg2?: any): Promise<IPager<IGalleryExtension>> {
|
||||
const options: IQueryOptions = CancellationToken.isCancellationToken(arg1) ? {} : arg1;
|
||||
const token: CancellationToken = CancellationToken.isCancellationToken(arg1) ? arg1 : arg2;
|
||||
|
||||
if (!this.isEnabled()) {
|
||||
return Promise.reject(new Error('No extension gallery service configured.'));
|
||||
}
|
||||
@@ -455,7 +460,7 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
|
||||
query = query.withSortOrder(options.sortOrder);
|
||||
}
|
||||
|
||||
return this.queryGallery(query, CancellationToken.None).then(({ galleryExtensions, total }) => {
|
||||
return this.queryGallery(query, token).then(({ galleryExtensions, total }) => {
|
||||
const extensions = galleryExtensions.map((e, index) => toExtension(e, e.versions[0], index, query, options.source));
|
||||
const pageSize = query.pageSize;
|
||||
const getPage = (pageIndex: number, ct: CancellationToken) => {
|
||||
|
||||
@@ -510,7 +510,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
|
||||
// filter out installed extensions
|
||||
const names = dependenciesAndPackExtensions.filter(id => installed.every(({ identifier: galleryIdentifier }) => !areSameExtensions(galleryIdentifier, { id })));
|
||||
if (names.length) {
|
||||
return this.galleryService.query({ names, pageSize: dependenciesAndPackExtensions.length })
|
||||
return this.galleryService.query({ names, pageSize: dependenciesAndPackExtensions.length }, CancellationToken.None)
|
||||
.then(galleryResult => {
|
||||
const extensionsToInstall = galleryResult.firstPage;
|
||||
return Promise.all(extensionsToInstall.map(async e => {
|
||||
@@ -590,11 +590,11 @@ export class ExtensionManagementService extends Disposable implements IExtension
|
||||
}
|
||||
|
||||
private findGalleryExtensionById(uuid: string): Promise<IGalleryExtension> {
|
||||
return this.galleryService.query({ ids: [uuid], pageSize: 1 }).then(galleryResult => galleryResult.firstPage[0]);
|
||||
return this.galleryService.query({ ids: [uuid], pageSize: 1 }, CancellationToken.None).then(galleryResult => galleryResult.firstPage[0]);
|
||||
}
|
||||
|
||||
private findGalleryExtensionByName(name: string): Promise<IGalleryExtension> {
|
||||
return this.galleryService.query({ names: [name], pageSize: 1 }).then(galleryResult => galleryResult.firstPage[0]);
|
||||
return this.galleryService.query({ names: [name], pageSize: 1 }, CancellationToken.None).then(galleryResult => galleryResult.firstPage[0]);
|
||||
}
|
||||
|
||||
private joinErrors(errorOrErrors: (Error | string) | (Array<Error | string>)): Error {
|
||||
|
||||
@@ -16,6 +16,7 @@ import { EnablementState } from 'vs/platform/extensionManagement/common/extensio
|
||||
import { areSameExtensions } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
|
||||
import { IWindowService } from 'vs/platform/windows/common/windows';
|
||||
import { IExtensionsWorkbenchService, IExtension } from 'vs/workbench/contrib/extensions/common/extensions';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
|
||||
@extHostNamedCustomer(MainContext.MainThreadExtensionService)
|
||||
export class MainThreadExtensionService implements MainThreadExtensionServiceShape {
|
||||
@@ -105,7 +106,7 @@ export class MainThreadExtensionService implements MainThreadExtensionServiceSha
|
||||
|
||||
private async _handleMissingNotInstalledDependency(extension: IExtensionDescription, missingDependency: string): Promise<void> {
|
||||
const extName = extension.displayName || extension.name;
|
||||
const dependencyExtension = (await this._extensionsWorkbenchService.queryGallery({ names: [missingDependency] })).firstPage[0];
|
||||
const dependencyExtension = (await this._extensionsWorkbenchService.queryGallery({ names: [missingDependency] }, CancellationToken.None)).firstPage[0];
|
||||
if (dependencyExtension) {
|
||||
this._notificationService.notify({
|
||||
severity: Severity.Error,
|
||||
|
||||
@@ -288,7 +288,9 @@ export class SimpleExtensionGalleryService implements IExtensionGalleryService {
|
||||
return false;
|
||||
}
|
||||
|
||||
query(options?: IQueryOptions): Promise<IPager<IGalleryExtension>> {
|
||||
query(token: CancellationToken): Promise<IPager<IGalleryExtension>>;
|
||||
query(options: IQueryOptions, token: CancellationToken): Promise<IPager<IGalleryExtension>>;
|
||||
query(arg1: any, arg2?: any): Promise<IPager<IGalleryExtension>> {
|
||||
// @ts-ignore
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ export class GalleryExtensionsHandler extends QuickOpenHandler {
|
||||
|
||||
getResults(text: string, token: CancellationToken): Promise<IModel<any>> {
|
||||
if (/\./.test(text)) {
|
||||
return this.galleryService.query({ names: [text], pageSize: 1 })
|
||||
return this.galleryService.query({ names: [text], pageSize: 1 }, token)
|
||||
.then(galleryResult => {
|
||||
const entries: SimpleEntry[] = [];
|
||||
const galleryExtension = galleryResult.firstPage[0];
|
||||
|
||||
@@ -83,7 +83,8 @@ export interface IExtensionsWorkbenchService {
|
||||
onChange: Event<IExtension | undefined>;
|
||||
local: IExtension[];
|
||||
queryLocal(): Promise<IExtension[]>;
|
||||
queryGallery(options?: IQueryOptions): Promise<IPager<IExtension>>;
|
||||
queryGallery(token: CancellationToken): Promise<IPager<IExtension>>;
|
||||
queryGallery(options: IQueryOptions, token: CancellationToken): Promise<IPager<IExtension>>;
|
||||
canInstall(extension: IExtension): boolean;
|
||||
install(vsix: string): Promise<IExtension>;
|
||||
install(extension: IExtension, promptToInstallDependencies?: boolean): Promise<IExtension>;
|
||||
|
||||
@@ -722,7 +722,7 @@ export class ExtensionEditor extends BaseEditor {
|
||||
getChildren(): Promise<IExtensionData[] | null> {
|
||||
if (this.hasChildren) {
|
||||
const names = arrays.distinct(this.extension.extensionPack, e => e.toLowerCase());
|
||||
return extensionsWorkbenchService.queryGallery({ names, pageSize: names.length })
|
||||
return extensionsWorkbenchService.queryGallery({ names, pageSize: names.length }, CancellationToken.None)
|
||||
.then(result => result.firstPage.map(extension => new ExtensionData(extension, this)));
|
||||
}
|
||||
return Promise.resolve(null);
|
||||
|
||||
@@ -373,7 +373,7 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
|
||||
|
||||
if (filteredWanted.length) {
|
||||
try {
|
||||
let validRecommendations = (await this._galleryService.query({ names: filteredWanted, pageSize: filteredWanted.length })).firstPage
|
||||
let validRecommendations = (await this._galleryService.query({ names: filteredWanted, pageSize: filteredWanted.length }, CancellationToken.None)).firstPage
|
||||
.map(extension => extension.identifier.id.toLowerCase());
|
||||
|
||||
if (validRecommendations.length !== filteredWanted.length) {
|
||||
@@ -760,7 +760,7 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
|
||||
|
||||
const lookup = product.extensionKeywords || {};
|
||||
const keywords = lookup[fileExtension] || [];
|
||||
this._galleryService.query({ text: `tag:"__ext_${fileExtension}" ${keywords.map(tag => `tag:"${tag}"`)}` }).then(pager => {
|
||||
this._galleryService.query({ text: `tag:"__ext_${fileExtension}" ${keywords.map(tag => `tag:"${tag}"`)}` }, CancellationToken.None).then(pager => {
|
||||
if (!pager || !pager.firstPage || !pager.firstPage.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ import { ExtensionActivationProgress } from 'vs/workbench/contrib/extensions/ele
|
||||
import { ExtensionsAutoProfiler } from 'vs/workbench/contrib/extensions/electron-browser/extensionsAutoProfiler';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { ExtensionDependencyChecker } from 'vs/workbench/contrib/extensions/electron-browser/extensionsDependencyChecker';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
|
||||
// Singletons
|
||||
registerSingleton(IExtensionsWorkbenchService, ExtensionsWorkbenchService);
|
||||
@@ -259,7 +260,7 @@ CommandsRegistry.registerCommand('_extensions.manage', (accessor: ServicesAccess
|
||||
CommandsRegistry.registerCommand('extension.open', (accessor: ServicesAccessor, extensionId: string) => {
|
||||
const extensionService = accessor.get(IExtensionsWorkbenchService);
|
||||
|
||||
return extensionService.queryGallery({ names: [extensionId], pageSize: 1 }).then(pager => {
|
||||
return extensionService.queryGallery({ names: [extensionId], pageSize: 1 }, CancellationToken.None).then(pager => {
|
||||
if (pager.total !== 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1514,7 +1514,7 @@ export class InstallWorkspaceRecommendedExtensionsAction extends Action {
|
||||
viewlet.search('@recommended ');
|
||||
viewlet.focus();
|
||||
const names = this.recommendations.map(({ extensionId }) => extensionId);
|
||||
return this.extensionWorkbenchService.queryGallery({ names, source: 'install-all-workspace-recommendations' }).then(pager => {
|
||||
return this.extensionWorkbenchService.queryGallery({ names, source: 'install-all-workspace-recommendations' }, CancellationToken.None).then(pager => {
|
||||
let installPromises: Promise<any>[] = [];
|
||||
let model = new PagedModel(pager);
|
||||
for (let i = 0; i < pager.total; i++) {
|
||||
@@ -1556,7 +1556,7 @@ export class InstallRecommendedExtensionAction extends Action {
|
||||
.then(viewlet => {
|
||||
viewlet.search('@recommended ');
|
||||
viewlet.focus();
|
||||
return this.extensionWorkbenchService.queryGallery({ names: [this.extensionId], source: 'install-recommendation', pageSize: 1 })
|
||||
return this.extensionWorkbenchService.queryGallery({ names: [this.extensionId], source: 'install-recommendation', pageSize: 1 }, CancellationToken.None)
|
||||
.then(pager => {
|
||||
if (pager && pager.firstPage && pager.firstPage.length) {
|
||||
const extension = pager.firstPage[0];
|
||||
|
||||
@@ -15,6 +15,7 @@ import { INotificationService, Severity } from 'vs/platform/notification/common/
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
import { IWindowService } from 'vs/platform/windows/common/windows';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
|
||||
export class ExtensionDependencyChecker extends Disposable implements IWorkbenchContribution {
|
||||
|
||||
@@ -60,7 +61,7 @@ export class ExtensionDependencyChecker extends Disposable implements IWorkbench
|
||||
private async installMissingDependencies(): Promise<void> {
|
||||
const missingDependencies = await this.getUninstalledMissingDependencies();
|
||||
if (missingDependencies.length) {
|
||||
const extensions = (await this.extensionsWorkbenchService.queryGallery({ names: missingDependencies, pageSize: missingDependencies.length })).firstPage;
|
||||
const extensions = (await this.extensionsWorkbenchService.queryGallery({ names: missingDependencies, pageSize: missingDependencies.length }, CancellationToken.None)).firstPage;
|
||||
if (extensions.length) {
|
||||
await Promise.all(extensions.map(extension => this.extensionsWorkbenchService.install(extension)));
|
||||
this.notificationService.notify({
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import 'vs/css!./media/extensionsViewlet';
|
||||
import { localize } from 'vs/nls';
|
||||
import { ThrottledDelayer, timeout } from 'vs/base/common/async';
|
||||
import { timeout, Delayer } from 'vs/base/common/async';
|
||||
import { isPromiseCanceledError } from 'vs/base/common/errors';
|
||||
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
@@ -270,7 +270,7 @@ export class ExtensionsViewlet extends ViewContainerViewlet implements IExtensio
|
||||
private recommendedExtensionsContextKey: IContextKey<boolean>;
|
||||
private defaultRecommendedExtensionsContextKey: IContextKey<boolean>;
|
||||
|
||||
private searchDelayer: ThrottledDelayer<any>;
|
||||
private searchDelayer: Delayer<void>;
|
||||
private root: HTMLElement;
|
||||
|
||||
private searchBox: SuggestEnabledInput;
|
||||
@@ -299,7 +299,7 @@ export class ExtensionsViewlet extends ViewContainerViewlet implements IExtensio
|
||||
) {
|
||||
super(VIEWLET_ID, `${VIEWLET_ID}.state`, true, configurationService, layoutService, telemetryService, storageService, instantiationService, themeService, contextMenuService, extensionService, contextService);
|
||||
|
||||
this.searchDelayer = new ThrottledDelayer(500);
|
||||
this.searchDelayer = new Delayer(500);
|
||||
this.nonEmptyWorkspaceContextKey = NonEmptyWorkspaceContext.bindTo(contextKeyService);
|
||||
this.searchExtensionsContextKey = SearchExtensionsContext.bindTo(contextKeyService);
|
||||
this.hasInstalledExtensionsContextKey = HasInstalledExtensionsContext.bindTo(contextKeyService);
|
||||
|
||||
@@ -44,6 +44,7 @@ import { IAction } from 'vs/base/common/actions';
|
||||
import { ExtensionType } from 'vs/platform/extensions/common/extensions';
|
||||
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
|
||||
import product from 'vs/platform/product/node/product';
|
||||
import { CancelablePromise, createCancelablePromise } from 'vs/base/common/async';
|
||||
|
||||
class ExtensionsViewState extends Disposable implements IExtensionsViewState {
|
||||
|
||||
@@ -69,6 +70,7 @@ export class ExtensionsListView extends ViewletPanel {
|
||||
private badge: CountBadge;
|
||||
protected badgeContainer: HTMLElement;
|
||||
private list: WorkbenchPagedList<IExtension> | null;
|
||||
private queryRequest: { query: string, request: CancelablePromise<IPagedModel<IExtension>> } | null;
|
||||
|
||||
constructor(
|
||||
private options: IViewletViewOptions,
|
||||
@@ -139,6 +141,14 @@ export class ExtensionsListView extends ViewletPanel {
|
||||
}
|
||||
|
||||
async show(query: string): Promise<IPagedModel<IExtension>> {
|
||||
if (this.queryRequest) {
|
||||
if (this.queryRequest.query === query) {
|
||||
return this.queryRequest.request;
|
||||
}
|
||||
this.queryRequest.request.cancel();
|
||||
this.queryRequest = null;
|
||||
}
|
||||
|
||||
const parsedQuery = Query.parse(query);
|
||||
|
||||
let options: IQueryOptions = {
|
||||
@@ -152,21 +162,23 @@ export class ExtensionsListView extends ViewletPanel {
|
||||
}
|
||||
|
||||
const successCallback = model => {
|
||||
this.queryRequest = null;
|
||||
this.setModel(model);
|
||||
return model;
|
||||
};
|
||||
const errorCallback = e => {
|
||||
console.warn('Error querying extensions gallery', e);
|
||||
const model = new PagedModel([]);
|
||||
this.setModel(model, true);
|
||||
return model;
|
||||
if (!isPromiseCanceledError(e)) {
|
||||
this.queryRequest = null;
|
||||
console.warn('Error querying extensions gallery', e);
|
||||
this.setModel(new PagedModel([]), true);
|
||||
}
|
||||
return this.list!.model;
|
||||
};
|
||||
|
||||
if (ExtensionsListView.isInstalledExtensionsQuery(query) || /@builtin/.test(query)) {
|
||||
return await this.queryLocal(parsedQuery, options).then(successCallback).catch(errorCallback);
|
||||
}
|
||||
|
||||
return await this.queryGallery(parsedQuery, options).then(successCallback).catch(errorCallback);
|
||||
const isLocalQuery = ExtensionsListView.isInstalledExtensionsQuery(query) || /@builtin/.test(query);
|
||||
const request = createCancelablePromise(token => (isLocalQuery ? this.queryLocal(parsedQuery, options) : this.queryGallery(parsedQuery, options, token)).then(successCallback).catch(errorCallback));
|
||||
this.queryRequest = { query, request };
|
||||
return request.then(successCallback).catch(errorCallback);
|
||||
}
|
||||
|
||||
count(): number {
|
||||
@@ -326,7 +338,7 @@ export class ExtensionsListView extends ViewletPanel {
|
||||
return new PagedModel([]);
|
||||
}
|
||||
|
||||
private async queryGallery(query: Query, options: IQueryOptions): Promise<IPagedModel<IExtension>> {
|
||||
private async queryGallery(query: Query, options: IQueryOptions, token: CancellationToken): Promise<IPagedModel<IExtension>> {
|
||||
const hasUserDefinedSortOrder = options.sortBy !== undefined;
|
||||
if (!hasUserDefinedSortOrder && !query.value.trim()) {
|
||||
options.sortBy = SortBy.InstallCount;
|
||||
@@ -343,22 +355,22 @@ export class ExtensionsListView extends ViewletPanel {
|
||||
}
|
||||
|
||||
if (names.length) {
|
||||
return this.extensionsWorkbenchService.queryGallery({ names, source: 'queryById' })
|
||||
return this.extensionsWorkbenchService.queryGallery({ names, source: 'queryById' }, token)
|
||||
.then(pager => this.getPagedModel(pager));
|
||||
}
|
||||
|
||||
if (ExtensionsListView.isWorkspaceRecommendedExtensionsQuery(query.value)) {
|
||||
return this.getWorkspaceRecommendationsModel(query, options);
|
||||
return this.getWorkspaceRecommendationsModel(query, options, token);
|
||||
} else if (ExtensionsListView.isKeymapsRecommendedExtensionsQuery(query.value)) {
|
||||
return this.getKeymapRecommendationsModel(query, options);
|
||||
return this.getKeymapRecommendationsModel(query, options, token);
|
||||
} else if (/@recommended:all/i.test(query.value) || ExtensionsListView.isSearchRecommendedExtensionsQuery(query.value)) {
|
||||
return this.getAllRecommendationsModel(query, options);
|
||||
return this.getAllRecommendationsModel(query, options, token);
|
||||
} else if (ExtensionsListView.isRecommendedExtensionsQuery(query.value)) {
|
||||
return this.getRecommendationsModel(query, options);
|
||||
return this.getRecommendationsModel(query, options, token);
|
||||
}
|
||||
|
||||
if (/\bcurated:([^\s]+)\b/.test(query.value)) {
|
||||
return this.getCuratedModel(query, options);
|
||||
return this.getCuratedModel(query, options, token);
|
||||
}
|
||||
|
||||
let text = query.value;
|
||||
@@ -382,7 +394,7 @@ export class ExtensionsListView extends ViewletPanel {
|
||||
|
||||
if (text !== query.value) {
|
||||
options = assign(options, { text: text.substr(0, 350), source: 'file-extension-tags' });
|
||||
return this.extensionsWorkbenchService.queryGallery(options).then(pager => this.getPagedModel(pager));
|
||||
return this.extensionsWorkbenchService.queryGallery(options, token).then(pager => this.getPagedModel(pager));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -403,7 +415,7 @@ export class ExtensionsListView extends ViewletPanel {
|
||||
options.source = 'viewlet';
|
||||
}
|
||||
|
||||
const pager = await this.extensionsWorkbenchService.queryGallery(options);
|
||||
const pager = await this.extensionsWorkbenchService.queryGallery(options, token);
|
||||
|
||||
let positionToUpdate = 0;
|
||||
for (const preferredResult of preferredResults) {
|
||||
@@ -450,7 +462,7 @@ export class ExtensionsListView extends ViewletPanel {
|
||||
}
|
||||
|
||||
// Get All types of recommendations, trimmed to show a max of 8 at any given time
|
||||
private getAllRecommendationsModel(query: Query, options: IQueryOptions): Promise<IPagedModel<IExtension>> {
|
||||
private getAllRecommendationsModel(query: Query, options: IQueryOptions, token: CancellationToken): Promise<IPagedModel<IExtension>> {
|
||||
const value = query.value.replace(/@recommended:all/g, '').replace(/@recommended/g, '').trim().toLowerCase();
|
||||
|
||||
return this.extensionsWorkbenchService.queryLocal()
|
||||
@@ -483,7 +495,7 @@ export class ExtensionsListView extends ViewletPanel {
|
||||
return Promise.resolve(new PagedModel([]));
|
||||
}
|
||||
options.source = 'recommendations-all';
|
||||
return this.extensionsWorkbenchService.queryGallery(assign(options, { names, pageSize: names.length }))
|
||||
return this.extensionsWorkbenchService.queryGallery(assign(options, { names, pageSize: names.length }), token)
|
||||
.then(pager => {
|
||||
this.sortFirstPage(pager, names);
|
||||
return this.getPagedModel(pager || []);
|
||||
@@ -492,12 +504,12 @@ export class ExtensionsListView extends ViewletPanel {
|
||||
});
|
||||
}
|
||||
|
||||
private async getCuratedModel(query: Query, options: IQueryOptions): Promise<IPagedModel<IExtension>> {
|
||||
private async getCuratedModel(query: Query, options: IQueryOptions, token: CancellationToken): Promise<IPagedModel<IExtension>> {
|
||||
const value = query.value.replace(/curated:/g, '').trim();
|
||||
const names = await this.experimentService.getCuratedExtensionsList(value);
|
||||
if (Array.isArray(names) && names.length) {
|
||||
options.source = `curated:${value}`;
|
||||
const pager = await this.extensionsWorkbenchService.queryGallery(assign(options, { names, pageSize: names.length }));
|
||||
const pager = await this.extensionsWorkbenchService.queryGallery(assign(options, { names, pageSize: names.length }), token);
|
||||
this.sortFirstPage(pager, names);
|
||||
return this.getPagedModel(pager || []);
|
||||
}
|
||||
@@ -505,7 +517,7 @@ export class ExtensionsListView extends ViewletPanel {
|
||||
}
|
||||
|
||||
// Get All types of recommendations other than Workspace recommendations, trimmed to show a max of 8 at any given time
|
||||
private getRecommendationsModel(query: Query, options: IQueryOptions): Promise<IPagedModel<IExtension>> {
|
||||
private getRecommendationsModel(query: Query, options: IQueryOptions, token: CancellationToken): Promise<IPagedModel<IExtension>> {
|
||||
const value = query.value.replace(/@recommended/g, '').trim().toLowerCase();
|
||||
|
||||
return this.extensionsWorkbenchService.queryLocal()
|
||||
@@ -543,7 +555,7 @@ export class ExtensionsListView extends ViewletPanel {
|
||||
return Promise.resolve(new PagedModel([]));
|
||||
}
|
||||
options.source = 'recommendations';
|
||||
return this.extensionsWorkbenchService.queryGallery(assign(options, { names, pageSize: names.length }))
|
||||
return this.extensionsWorkbenchService.queryGallery(assign(options, { names, pageSize: names.length }), token)
|
||||
.then(pager => {
|
||||
this.sortFirstPage(pager, names);
|
||||
return this.getPagedModel(pager || []);
|
||||
@@ -585,7 +597,7 @@ export class ExtensionsListView extends ViewletPanel {
|
||||
return installed.some(i => areSameExtensions(i.identifier, { id: recommendation.extensionId }));
|
||||
}
|
||||
|
||||
private getWorkspaceRecommendationsModel(query: Query, options: IQueryOptions): Promise<IPagedModel<IExtension>> {
|
||||
private getWorkspaceRecommendationsModel(query: Query, options: IQueryOptions, token: CancellationToken): Promise<IPagedModel<IExtension>> {
|
||||
const value = query.value.replace(/@recommended:workspace/g, '').trim().toLowerCase();
|
||||
return this.tipsService.getWorkspaceRecommendations()
|
||||
.then(recommendations => {
|
||||
@@ -601,12 +613,12 @@ export class ExtensionsListView extends ViewletPanel {
|
||||
return Promise.resolve(new PagedModel([]));
|
||||
}
|
||||
options.source = 'recommendations-workspace';
|
||||
return this.extensionsWorkbenchService.queryGallery(assign(options, { names, pageSize: names.length }))
|
||||
return this.extensionsWorkbenchService.queryGallery(assign(options, { names, pageSize: names.length }), token)
|
||||
.then(pager => this.getPagedModel(pager || []));
|
||||
});
|
||||
}
|
||||
|
||||
private getKeymapRecommendationsModel(query: Query, options: IQueryOptions): Promise<IPagedModel<IExtension>> {
|
||||
private getKeymapRecommendationsModel(query: Query, options: IQueryOptions, token: CancellationToken): Promise<IPagedModel<IExtension>> {
|
||||
const value = query.value.replace(/@recommended:keymaps/g, '').trim().toLowerCase();
|
||||
const names: string[] = this.tipsService.getKeymapRecommendations().map(({ extensionId }) => extensionId)
|
||||
.filter(extensionId => extensionId.toLowerCase().indexOf(value) > -1);
|
||||
@@ -615,7 +627,7 @@ export class ExtensionsListView extends ViewletPanel {
|
||||
return Promise.resolve(new PagedModel([]));
|
||||
}
|
||||
options.source = 'recommendations-keymaps';
|
||||
return this.extensionsWorkbenchService.queryGallery(assign(options, { names, pageSize: names.length }))
|
||||
return this.extensionsWorkbenchService.queryGallery(assign(options, { names, pageSize: names.length }), token)
|
||||
.then(result => this.getPagedModel(result));
|
||||
}
|
||||
|
||||
@@ -696,6 +708,10 @@ export class ExtensionsListView extends ViewletPanel {
|
||||
|
||||
dispose(): void {
|
||||
super.dispose();
|
||||
if (this.queryRequest) {
|
||||
this.queryRequest.request.cancel();
|
||||
this.queryRequest = null;
|
||||
}
|
||||
this.disposables = dispose(this.disposables);
|
||||
this.list = null;
|
||||
}
|
||||
|
||||
@@ -442,12 +442,16 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService,
|
||||
});
|
||||
}
|
||||
|
||||
queryGallery(options: IQueryOptions = {}): Promise<IPager<IExtension>> {
|
||||
queryGallery(token: CancellationToken): Promise<IPager<IExtension>>;
|
||||
queryGallery(options: IQueryOptions, token: CancellationToken): Promise<IPager<IExtension>>;
|
||||
queryGallery(arg1: any, arg2?: any): Promise<IPager<IExtension>> {
|
||||
const options: IQueryOptions = CancellationToken.isCancellationToken(arg1) ? {} : arg1;
|
||||
const token: CancellationToken = CancellationToken.isCancellationToken(arg1) ? arg1 : arg2;
|
||||
return this.extensionService.getExtensionsReport()
|
||||
.then(report => {
|
||||
const maliciousSet = getMaliciousExtensionsSet(report);
|
||||
|
||||
return this.galleryService.query(options)
|
||||
return this.galleryService.query(options, token)
|
||||
.then(result => mapPager(result, gallery => this.fromGallery(gallery, maliciousSet)))
|
||||
.then(undefined, err => {
|
||||
if (/No extension gallery service configured/.test(err.message)) {
|
||||
@@ -589,10 +593,10 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService,
|
||||
|
||||
const promises: Promise<IPager<IExtension>>[] = [];
|
||||
if (ids.length) {
|
||||
promises.push(this.queryGallery({ ids, pageSize: ids.length }));
|
||||
promises.push(this.queryGallery({ ids, pageSize: ids.length }, CancellationToken.None));
|
||||
}
|
||||
if (names.length) {
|
||||
promises.push(this.queryGallery({ names, pageSize: names.length }));
|
||||
promises.push(this.queryGallery({ names, pageSize: names.length }, CancellationToken.None));
|
||||
}
|
||||
|
||||
return Promise.all(promises).then(() => undefined);
|
||||
@@ -994,7 +998,7 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService,
|
||||
.then(() => this.open(extension));
|
||||
}
|
||||
|
||||
return this.queryGallery({ names: [extensionId], source: 'uri' }).then(result => {
|
||||
return this.queryGallery({ names: [extensionId], source: 'uri' }, CancellationToken.None).then(result => {
|
||||
if (result.total < 1) {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
+26
-25
@@ -38,6 +38,7 @@ import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteA
|
||||
import { RemoteAgentService } from 'vs/workbench/services/remote/electron-browser/remoteAgentServiceImpl';
|
||||
import { ExtensionIdentifier, IExtensionContributions, ExtensionType, IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
|
||||
suite('ExtensionsActions Test', () => {
|
||||
|
||||
@@ -110,7 +111,7 @@ suite('ExtensionsActions Test', () => {
|
||||
return workbenchService.queryLocal()
|
||||
.then(() => {
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(aGalleryExtension('a', { identifier: local.identifier })));
|
||||
return workbenchService.queryGallery()
|
||||
return workbenchService.queryGallery(CancellationToken.None)
|
||||
.then((paged) => {
|
||||
testObject.extension = paged.firstPage[0];
|
||||
assert.ok(!testObject.enabled);
|
||||
@@ -126,7 +127,7 @@ suite('ExtensionsActions Test', () => {
|
||||
instantiationService.get(IExtensionsWorkbenchService).onChange(() => testObject.update());
|
||||
const gallery = aGalleryExtension('a');
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
|
||||
return workbenchService.queryGallery()
|
||||
return workbenchService.queryGallery(CancellationToken.None)
|
||||
.then((paged) => {
|
||||
testObject.extension = paged.firstPage[0];
|
||||
installEvent.fire({ identifier: gallery.identifier, gallery });
|
||||
@@ -143,7 +144,7 @@ suite('ExtensionsActions Test', () => {
|
||||
instantiationService.get(IExtensionsWorkbenchService).onChange(() => testObject.update());
|
||||
const gallery = aGalleryExtension('a');
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
|
||||
return workbenchService.queryGallery()
|
||||
return workbenchService.queryGallery(CancellationToken.None)
|
||||
.then((paged) => {
|
||||
testObject.extension = paged.firstPage[0];
|
||||
assert.ok(testObject.enabled);
|
||||
@@ -257,7 +258,7 @@ suite('ExtensionsActions Test', () => {
|
||||
const gallery = aGalleryExtension('a');
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
|
||||
|
||||
return instantiationService.get(IExtensionsWorkbenchService).queryGallery()
|
||||
return instantiationService.get(IExtensionsWorkbenchService).queryGallery(CancellationToken.None)
|
||||
.then(paged => {
|
||||
testObject.extension = paged.firstPage[0];
|
||||
|
||||
@@ -299,7 +300,7 @@ suite('ExtensionsActions Test', () => {
|
||||
const gallery = aGalleryExtension('a');
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
|
||||
|
||||
return workbenchService.queryGallery()
|
||||
return workbenchService.queryGallery(CancellationToken.None)
|
||||
.then((paged) => {
|
||||
testObject.extension = paged.firstPage[0];
|
||||
assert.ok(testObject.enabled);
|
||||
@@ -329,7 +330,7 @@ suite('ExtensionsActions Test', () => {
|
||||
const workbenchService = instantiationService.get(IExtensionsWorkbenchService);
|
||||
const gallery = aGalleryExtension('a');
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
|
||||
return workbenchService.queryGallery()
|
||||
return workbenchService.queryGallery(CancellationToken.None)
|
||||
.then((paged) => {
|
||||
testObject.extension = paged.firstPage[0];
|
||||
installEvent.fire({ identifier: gallery.identifier, gallery });
|
||||
@@ -387,7 +388,7 @@ suite('ExtensionsActions Test', () => {
|
||||
instantiationService.get(IExtensionsWorkbenchService).onChange(() => testObject.update());
|
||||
const gallery = aGalleryExtension('a', { version: '1.0.0' });
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
|
||||
return instantiationService.get(IExtensionsWorkbenchService).queryGallery()
|
||||
return instantiationService.get(IExtensionsWorkbenchService).queryGallery(CancellationToken.None)
|
||||
.then((paged) => {
|
||||
testObject.extension = paged.firstPage[0];
|
||||
assert.ok(!testObject.enabled);
|
||||
@@ -404,7 +405,7 @@ suite('ExtensionsActions Test', () => {
|
||||
.then(extensions => {
|
||||
testObject.extension = extensions[0];
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(aGalleryExtension('a', { identifier: local.identifier, version: local.manifest.version })));
|
||||
return instantiationService.get(IExtensionsWorkbenchService).queryGallery()
|
||||
return instantiationService.get(IExtensionsWorkbenchService).queryGallery(CancellationToken.None)
|
||||
.then(extensions => assert.ok(!testObject.enabled));
|
||||
});
|
||||
});
|
||||
@@ -419,7 +420,7 @@ suite('ExtensionsActions Test', () => {
|
||||
.then(extensions => {
|
||||
testObject.extension = extensions[0];
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(aGalleryExtension('a', { identifier: local.identifier, version: '1.0.1' })));
|
||||
return instantiationService.get(IExtensionsWorkbenchService).queryGallery()
|
||||
return instantiationService.get(IExtensionsWorkbenchService).queryGallery(CancellationToken.None)
|
||||
.then(extensions => assert.ok(!testObject.enabled));
|
||||
});
|
||||
});
|
||||
@@ -442,7 +443,7 @@ suite('ExtensionsActions Test', () => {
|
||||
c();
|
||||
}
|
||||
});
|
||||
instantiationService.get(IExtensionsWorkbenchService).queryGallery();
|
||||
instantiationService.get(IExtensionsWorkbenchService).queryGallery(CancellationToken.None);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -458,7 +459,7 @@ suite('ExtensionsActions Test', () => {
|
||||
testObject.extension = extensions[0];
|
||||
const gallery = aGalleryExtension('a', { identifier: local.identifier, version: '1.0.1' });
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
|
||||
return instantiationService.get(IExtensionsWorkbenchService).queryGallery()
|
||||
return instantiationService.get(IExtensionsWorkbenchService).queryGallery(CancellationToken.None)
|
||||
.then(extensions => {
|
||||
installEvent.fire({ identifier: local.identifier, gallery });
|
||||
assert.ok(!testObject.enabled);
|
||||
@@ -494,7 +495,7 @@ suite('ExtensionsActions Test', () => {
|
||||
const gallery = aGalleryExtension('a');
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
|
||||
|
||||
return instantiationService.get(IExtensionsWorkbenchService).queryGallery()
|
||||
return instantiationService.get(IExtensionsWorkbenchService).queryGallery(CancellationToken.None)
|
||||
.then(page => {
|
||||
testObject.extension = page.firstPage[0];
|
||||
assert.ok(!testObject.enabled);
|
||||
@@ -509,7 +510,7 @@ suite('ExtensionsActions Test', () => {
|
||||
const gallery = aGalleryExtension('a');
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
|
||||
|
||||
return instantiationService.get(IExtensionsWorkbenchService).queryGallery()
|
||||
return instantiationService.get(IExtensionsWorkbenchService).queryGallery(CancellationToken.None)
|
||||
.then(page => {
|
||||
testObject.extension = page.firstPage[0];
|
||||
|
||||
@@ -526,7 +527,7 @@ suite('ExtensionsActions Test', () => {
|
||||
const gallery = aGalleryExtension('a');
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
|
||||
|
||||
return instantiationService.get(IExtensionsWorkbenchService).queryGallery()
|
||||
return instantiationService.get(IExtensionsWorkbenchService).queryGallery(CancellationToken.None)
|
||||
.then(page => {
|
||||
testObject.extension = page.firstPage[0];
|
||||
installEvent.fire({ identifier: gallery.identifier, gallery });
|
||||
@@ -750,7 +751,7 @@ suite('ExtensionsActions Test', () => {
|
||||
const gallery = aGalleryExtension('a');
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
|
||||
|
||||
return instantiationService.get(IExtensionsWorkbenchService).queryGallery()
|
||||
return instantiationService.get(IExtensionsWorkbenchService).queryGallery(CancellationToken.None)
|
||||
.then(page => {
|
||||
const testObject: ExtensionsActions.EnableDropDownAction = instantiationService.createInstance(ExtensionsActions.EnableDropDownAction);
|
||||
testObject.extension = page.firstPage[0];
|
||||
@@ -762,7 +763,7 @@ suite('ExtensionsActions Test', () => {
|
||||
const gallery = aGalleryExtension('a');
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
|
||||
|
||||
return instantiationService.get(IExtensionsWorkbenchService).queryGallery()
|
||||
return instantiationService.get(IExtensionsWorkbenchService).queryGallery(CancellationToken.None)
|
||||
.then(page => {
|
||||
const testObject: ExtensionsActions.EnableDropDownAction = instantiationService.createInstance(ExtensionsActions.EnableDropDownAction);
|
||||
testObject.extension = page.firstPage[0];
|
||||
@@ -934,7 +935,7 @@ suite('ExtensionsActions Test', () => {
|
||||
const gallery = aGalleryExtension('a');
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
|
||||
|
||||
return instantiationService.get(IExtensionsWorkbenchService).queryGallery()
|
||||
return instantiationService.get(IExtensionsWorkbenchService).queryGallery(CancellationToken.None)
|
||||
.then(page => {
|
||||
const testObject: ExtensionsActions.DisableDropDownAction = instantiationService.createInstance(ExtensionsActions.DisableDropDownAction, [{ identifier: new ExtensionIdentifier('pub.a'), extensionLocation: URI.file('pub.a') }]);
|
||||
testObject.extension = page.firstPage[0];
|
||||
@@ -946,7 +947,7 @@ suite('ExtensionsActions Test', () => {
|
||||
const gallery = aGalleryExtension('a');
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
|
||||
|
||||
return instantiationService.get(IExtensionsWorkbenchService).queryGallery()
|
||||
return instantiationService.get(IExtensionsWorkbenchService).queryGallery(CancellationToken.None)
|
||||
.then(page => {
|
||||
const testObject: ExtensionsActions.DisableDropDownAction = instantiationService.createInstance(ExtensionsActions.DisableDropDownAction, [{ identifier: new ExtensionIdentifier('pub.a'), extensionLocation: URI.file('pub.a') }]);
|
||||
testObject.extension = page.firstPage[0];
|
||||
@@ -998,7 +999,7 @@ suite('ExtensionsActions Test', () => {
|
||||
c();
|
||||
}
|
||||
});
|
||||
workbenchService.queryGallery();
|
||||
workbenchService.queryGallery(CancellationToken.None);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1020,7 +1021,7 @@ suite('ExtensionsActions Test', () => {
|
||||
c();
|
||||
}
|
||||
});
|
||||
workbenchService.queryGallery();
|
||||
workbenchService.queryGallery(CancellationToken.None);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1034,7 +1035,7 @@ suite('ExtensionsActions Test', () => {
|
||||
return workbenchService.queryLocal()
|
||||
.then(() => {
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(...gallery));
|
||||
return workbenchService.queryGallery()
|
||||
return workbenchService.queryGallery(CancellationToken.None)
|
||||
.then(() => {
|
||||
installEvent.fire({ identifier: local[0].identifier, gallery: gallery[0] });
|
||||
installEvent.fire({ identifier: local[1].identifier, gallery: gallery[1] });
|
||||
@@ -1056,7 +1057,7 @@ suite('ExtensionsActions Test', () => {
|
||||
const workbenchService = instantiationService.get(IExtensionsWorkbenchService);
|
||||
const gallery = aGalleryExtension('a');
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
|
||||
return workbenchService.queryGallery()
|
||||
return workbenchService.queryGallery(CancellationToken.None)
|
||||
.then((paged) => {
|
||||
testObject.extension = paged.firstPage[0];
|
||||
installEvent.fire({ identifier: gallery.identifier, gallery });
|
||||
@@ -1086,7 +1087,7 @@ suite('ExtensionsActions Test', () => {
|
||||
const gallery = aGalleryExtension('a');
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
|
||||
|
||||
const paged = await instantiationService.get(IExtensionsWorkbenchService).queryGallery();
|
||||
const paged = await instantiationService.get(IExtensionsWorkbenchService).queryGallery(CancellationToken.None);
|
||||
testObject.extension = paged.firstPage[0];
|
||||
assert.ok(!testObject.enabled);
|
||||
|
||||
@@ -1107,7 +1108,7 @@ suite('ExtensionsActions Test', () => {
|
||||
instantiationService.get(IExtensionsWorkbenchService).onChange(() => testObject.update());
|
||||
const gallery = aGalleryExtension('a');
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
|
||||
return instantiationService.get(IExtensionsWorkbenchService).queryGallery()
|
||||
return instantiationService.get(IExtensionsWorkbenchService).queryGallery(CancellationToken.None)
|
||||
.then((paged) => {
|
||||
testObject.extension = paged.firstPage[0];
|
||||
const identifier = gallery.identifier;
|
||||
@@ -1314,7 +1315,7 @@ suite('ExtensionsActions Test', () => {
|
||||
const gallery = aGalleryExtension('a');
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
|
||||
|
||||
const paged = await instantiationService.get(IExtensionsWorkbenchService).queryGallery();
|
||||
const paged = await instantiationService.get(IExtensionsWorkbenchService).queryGallery(CancellationToken.None);
|
||||
testObject.extension = paged.firstPage[0];
|
||||
assert.ok(!testObject.enabled);
|
||||
|
||||
|
||||
+11
-11
@@ -131,7 +131,7 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
||||
testObject = await aWorkbenchService();
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(expected));
|
||||
|
||||
return testObject.queryGallery().then(pagedResponse => {
|
||||
return testObject.queryGallery(CancellationToken.None).then(pagedResponse => {
|
||||
assert.equal(1, pagedResponse.firstPage.length);
|
||||
const actual = pagedResponse.firstPage[0];
|
||||
|
||||
@@ -330,7 +330,7 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
||||
testObject = await aWorkbenchService();
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
|
||||
|
||||
return testObject.queryGallery().then(page => {
|
||||
return testObject.queryGallery(CancellationToken.None).then(page => {
|
||||
const extension = page.firstPage[0];
|
||||
assert.equal(ExtensionState.Uninstalled, extension.state);
|
||||
|
||||
@@ -414,7 +414,7 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
|
||||
const target = sinon.spy();
|
||||
|
||||
return testObject.queryGallery().then(page => {
|
||||
return testObject.queryGallery(CancellationToken.None).then(page => {
|
||||
const extension = page.firstPage[0];
|
||||
assert.equal(ExtensionState.Uninstalled, extension.state);
|
||||
|
||||
@@ -435,7 +435,7 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
|
||||
const target = sinon.spy();
|
||||
|
||||
return testObject.queryGallery().then(page => {
|
||||
return testObject.queryGallery(CancellationToken.None).then(page => {
|
||||
const extension = page.firstPage[0];
|
||||
assert.equal(ExtensionState.Uninstalled, extension.state);
|
||||
|
||||
@@ -480,7 +480,7 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
||||
testObject = await aWorkbenchService();
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(aGalleryExtension('a')));
|
||||
|
||||
return testObject.queryGallery().then(page => {
|
||||
return testObject.queryGallery(CancellationToken.None).then(page => {
|
||||
return testObject.loadDependencies(page.firstPage[0], CancellationToken.None).then(dependencies => {
|
||||
assert.equal(null, dependencies);
|
||||
});
|
||||
@@ -492,7 +492,7 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(aGalleryExtension('a', {}, { dependencies: ['pub.b', 'pub.c', 'pub.d'] })));
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'loadAllDependencies', [aGalleryExtension('b'), aGalleryExtension('c'), aGalleryExtension('d')]);
|
||||
|
||||
return testObject.queryGallery().then(page => {
|
||||
return testObject.queryGallery(CancellationToken.None).then(page => {
|
||||
const extension = page.firstPage[0];
|
||||
return testObject.loadDependencies(extension, CancellationToken.None).then(actual => {
|
||||
assert.ok(actual!.hasDependencies);
|
||||
@@ -531,7 +531,7 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(aGalleryExtension('a', {}, { dependencies: ['pub.b', 'pub.a'] })));
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'loadAllDependencies', [aGalleryExtension('b'), aGalleryExtension('a')]);
|
||||
|
||||
return testObject.queryGallery().then(page => {
|
||||
return testObject.queryGallery(CancellationToken.None).then(page => {
|
||||
const extension = page.firstPage[0];
|
||||
return testObject.loadDependencies(extension, CancellationToken.None).then(actual => {
|
||||
assert.ok(actual!.hasDependencies);
|
||||
@@ -563,7 +563,7 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(aGalleryExtension('a', {}, { dependencies: ['pub.b', 'pub.a'] })));
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'loadAllDependencies', [aGalleryExtension('a')]);
|
||||
|
||||
return testObject.queryGallery().then(page => {
|
||||
return testObject.queryGallery(CancellationToken.None).then(page => {
|
||||
const extension = page.firstPage[0];
|
||||
return testObject.loadDependencies(extension, CancellationToken.None).then(actual => {
|
||||
assert.ok(actual!.hasDependencies);
|
||||
@@ -597,7 +597,7 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(aGalleryExtension('a', {}, { dependencies: ['pub.inbuilt', 'pub.a'] })));
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'loadAllDependencies', [aGalleryExtension('a')]);
|
||||
|
||||
return testObject.queryGallery().then(page => {
|
||||
return testObject.queryGallery(CancellationToken.None).then(page => {
|
||||
const extension = page.firstPage[0];
|
||||
return testObject.loadDependencies(extension, CancellationToken.None).then(actual => {
|
||||
assert.ok(actual!.hasDependencies);
|
||||
@@ -635,7 +635,7 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
||||
aGalleryExtension('d', {}, { dependencies: ['pub.f', 'pub.c'] }),
|
||||
aGalleryExtension('e')]);
|
||||
|
||||
return testObject.queryGallery().then(page => {
|
||||
return testObject.queryGallery(CancellationToken.None).then(page => {
|
||||
const extension = page.firstPage[0];
|
||||
return testObject.loadDependencies(extension, CancellationToken.None).then(a => {
|
||||
assert.ok(a!.hasDependencies);
|
||||
@@ -724,7 +724,7 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
||||
.then(async () => {
|
||||
testObject = await aWorkbenchService();
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(aGalleryExtension('a')));
|
||||
return testObject.queryGallery().then(pagedResponse => {
|
||||
return testObject.queryGallery(CancellationToken.None).then(pagedResponse => {
|
||||
const actual = pagedResponse.firstPage[0];
|
||||
assert.equal(actual.enablementState, EnablementState.Enabled);
|
||||
});
|
||||
|
||||
@@ -118,7 +118,7 @@ export class LocalizationWorkbenchContribution extends Disposable implements IWo
|
||||
return;
|
||||
}
|
||||
|
||||
this.galleryService.query({ text: `tag:lp-${locale}` }).then(tagResult => {
|
||||
this.galleryService.query({ text: `tag:lp-${locale}` }, CancellationToken.None).then(tagResult => {
|
||||
if (tagResult.total === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import { IExperimentService, ExperimentState } from 'vs/workbench/contrib/experi
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { language, locale } from 'vs/base/common/platform';
|
||||
import { IExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
|
||||
export class TelemetryOptOut implements IWorkbenchContribution {
|
||||
|
||||
@@ -84,7 +85,7 @@ export class TelemetryOptOut implements IWorkbenchContribution {
|
||||
|
||||
let queryPromise = Promise.resolve(undefined);
|
||||
if (locale && locale !== language && locale !== 'en' && locale.indexOf('en-') === -1) {
|
||||
queryPromise = this.galleryService.query({ text: `tag:lp-${locale}` }).then(tagResult => {
|
||||
queryPromise = this.galleryService.query({ text: `tag:lp-${locale}` }, CancellationToken.None).then(tagResult => {
|
||||
if (!tagResult || !tagResult.total) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { ExtensionType } from 'vs/platform/extensions/common/extensions';
|
||||
import { joinPath } from 'vs/base/common/resources';
|
||||
import { IRecentlyOpened, isRecentWorkspace, IRecentWorkspace, IRecentFolder, isRecentFolder } from 'vs/platform/history/common/history';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
|
||||
used();
|
||||
|
||||
@@ -455,7 +456,7 @@ class WelcomePage {
|
||||
this.notificationService.info(strings.alreadyInstalled.replace('{0}', extensionSuggestion.name));
|
||||
return;
|
||||
}
|
||||
const foundAndInstalled = installedExtension ? Promise.resolve(installedExtension.local) : this.extensionGalleryService.query({ names: [extensionSuggestion.id], source: telemetryFrom })
|
||||
const foundAndInstalled = installedExtension ? Promise.resolve(installedExtension.local) : this.extensionGalleryService.query({ names: [extensionSuggestion.id], source: telemetryFrom }, CancellationToken.None)
|
||||
.then((result): null | Promise<ILocalExtension | null> => {
|
||||
const [extension] = result.firstPage;
|
||||
if (!extension) {
|
||||
@@ -550,7 +551,7 @@ class WelcomePage {
|
||||
from: telemetryFrom,
|
||||
extensionId: extensionSuggestion.id,
|
||||
});
|
||||
this.extensionsWorkbenchService.queryGallery({ names: [extensionSuggestion.id] })
|
||||
this.extensionsWorkbenchService.queryGallery({ names: [extensionSuggestion.id] }, CancellationToken.None)
|
||||
.then(result => this.extensionsWorkbenchService.open(result.firstPage[0]))
|
||||
.then(undefined, onUnexpectedError);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user