Merge from vscode 966b87dd4013be1a9c06e2b8334522ec61905cc2 (#4696)

This commit is contained in:
Anthony Dresser
2019-03-26 11:43:38 -07:00
committed by GitHub
parent b1393ae615
commit 0d8ef9583b
268 changed files with 5947 additions and 3422 deletions

View File

@@ -86,7 +86,7 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
private _workspaceIgnoredRecommendations: string[] = [];
private _extensionsRecommendationsUrl: string;
private _disposables: IDisposable[] = [];
public loadWorkspaceConfigPromise: Promise<any>;
public loadWorkspaceConfigPromise: Promise<void>;
private proactiveRecommendationsFetched: boolean = false;
private readonly _onRecommendationChange = new Emitter<RecommendationChangeNotification>();
@@ -137,7 +137,7 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
}
// {{SQL CARBON EDIT}} disable extension recommendation prompt
this.loadWorkspaceConfigPromise = this.getWorkspaceRecommendations();
this.loadWorkspaceConfigPromise = this.getWorkspaceRecommendations().then();
// .then(() => {
// this.promptWorkspaceRecommendations();
// this._modelService.onModelAdded(this.promptFiletypeBasedRecommendations, this, this._disposables);
@@ -879,7 +879,7 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
/**
* If user has any of the tools listed in product.exeBasedExtensionTips, fetch corresponding recommendations
*/
private fetchExecutableRecommendations(): Promise<any> {
private fetchExecutableRecommendations(): Promise<void> {
const homeDir = os.homedir();
let foundExecutables: Set<string> = new Set<string>();
@@ -897,7 +897,7 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
});
};
let promises: Promise<any>[] = [];
let promises: Promise<void>[] = [];
// Loop through recommended extensions
forEach(product.exeBasedExtensionTips, entry => {
if (typeof entry.value !== 'object' || !Array.isArray(entry.value['recommendations'])) {
@@ -921,7 +921,7 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
}
});
return Promise.all(promises);
return Promise.all(promises).then(() => undefined);
}
/**
@@ -1016,17 +1016,18 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
* Fetch extension recommendations from currently running experiments
*/
private fetchExperimentalRecommendations() {
// {{SQL CARBON EDIT}} disable experiements
// this.experimentService.getExperimentsByType(ExperimentActionType.AddToRecommendations).then(experiments => {
// (experiments || []).forEach(experiment => {
// const action = experiment.action;
// if (action && experiment.state === ExperimentState.Run && action.properties && Array.isArray(action.properties.recommendations) && action.properties.recommendationReason) {
// action.properties.recommendations.forEach(id => {
// this._experimentalRecommendations[id] = action.properties.recommendationReason;
// });
// }
// });
// });
/* // {{SQL CARBON EDIT}} disable experiements
this.experimentService.getExperimentsByType(ExperimentActionType.AddToRecommendations).then(experiments => {
(experiments || []).forEach(experiment => {
const action = experiment.action;
if (action && experiment.state === ExperimentState.Run && action.properties && Array.isArray(action.properties.recommendations) && action.properties.recommendationReason) {
action.properties.recommendations.forEach((id: string) => {
this._experimentalRecommendations[id] = action.properties.recommendationReason;
});
}
});
});
*/
}
//#endregion

View File

@@ -340,13 +340,13 @@ export class ExtensionsViewlet extends ViewContainerViewlet implements IExtensio
this.searchBox = this.instantiationService.createInstance(SuggestEnabledInput, `${VIEWLET_ID}.searchbox`, header, {
triggerCharacters: ['@'],
sortKey: item => {
sortKey: (item: string) => {
if (item.indexOf(':') === -1) { return 'a'; }
else if (/ext:/.test(item) || /tag:/.test(item)) { return 'b'; }
else if (/sort:/.test(item)) { return 'c'; }
else { return 'd'; }
},
provideResults: (query) => Query.suggestions(query)
provideResults: (query: string) => Query.suggestions(query)
}, placeholder, 'extensions:searchinput', { placeholderText: placeholder, value: searchValue });
if (this.searchBox.getValue()) {
@@ -453,7 +453,7 @@ export class ExtensionsViewlet extends ViewContainerViewlet implements IExtensio
super.saveState();
}
private doSearch(): Promise<any> {
private doSearch(): Promise<void> {
const value = this.normalizedQuery();
this.searchExtensionsContextKey.set(!!value);
this.searchBuiltInExtensionsContextKey.set(ExtensionsListView.isBuiltInExtensionsQuery(value));
@@ -465,9 +465,9 @@ export class ExtensionsViewlet extends ViewContainerViewlet implements IExtensio
return this.progress(Promise.all(this.panels.map(view =>
(<ExtensionsListView>view).show(this.normalizedQuery())
.then(model => this.alertSearchResult(model.length, view.id))
)));
))).then(() => undefined);
}
return Promise.resolve(null);
return Promise.resolve();
}
protected onDidAddViews(added: IAddedViewDescriptorRef[]): ViewletPanel[] {
@@ -479,7 +479,7 @@ export class ExtensionsViewlet extends ViewContainerViewlet implements IExtensio
return addedViews;
}
private alertSearchResult(count: number, viewId: string) {
private alertSearchResult(count: number, viewId: string): void {
switch (count) {
case 0:
break;
@@ -531,7 +531,7 @@ export class ExtensionsViewlet extends ViewContainerViewlet implements IExtensio
return this.progressService.withProgress({ location: ProgressLocation.Extensions }, () => promise);
}
private onError(err: any): void {
private onError(err: Error): void {
if (isPromiseCanceledError(err)) {
return;
}
@@ -614,7 +614,7 @@ export class MaliciousExtensionChecker implements IWorkbenchContribution {
.then(() => this.loopCheckForMaliciousExtensions());
}
private checkForMaliciousExtensions(): Promise<any> {
private checkForMaliciousExtensions(): Promise<void> {
return this.extensionsManagementService.getExtensionsReport().then(report => {
const maliciousSet = getMaliciousExtensionsSet(report);
@@ -635,9 +635,9 @@ export class MaliciousExtensionChecker implements IWorkbenchContribution {
);
})));
} else {
return Promise.resolve(null);
return Promise.resolve(undefined);
}
});
}).then(() => undefined);
}, err => this.logService.error(err));
}

View File

@@ -178,10 +178,9 @@ export class ExtensionsListView extends ViewletPanel {
return this.list ? this.list.model : model;
};
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));
const request = createCancelablePromise(token => this.query(parsedQuery, options, token).then(successCallback).catch(errorCallback));
this.queryRequest = { query, request };
return request.then(successCallback).catch(errorCallback);
return request;
}
count(): number {
@@ -215,6 +214,36 @@ export class ExtensionsListView extends ViewletPanel {
}
}
private async query(query: Query, options: IQueryOptions, token: CancellationToken): Promise<IPagedModel<IExtension>> {
const idRegex = /@id:(([a-z0-9A-Z][a-z0-9\-A-Z]*)\.([a-z0-9A-Z][a-z0-9\-A-Z]*))/g;
const ids: string[] = [];
let idMatch;
while ((idMatch = idRegex.exec(query.value)) !== null) {
const name = idMatch[1];
ids.push(name);
}
if (ids.length) {
return this.queryByIds(ids, options, token);
}
if (ExtensionsListView.isInstalledExtensionsQuery(query.value) || /@builtin/.test(query.value)) {
return this.queryLocal(query, options);
}
return this.queryGallery(query, options, token);
}
private async queryByIds(ids: string[], options: IQueryOptions, token: CancellationToken): Promise<IPagedModel<IExtension>> {
const idsSet: Set<string> = ids.reduce((result, id) => { result.add(id.toLowerCase()); return result; }, new Set<string>());
const result = (await this.extensionsWorkbenchService.queryLocal())
.filter(e => idsSet.has(e.identifier.id.toLowerCase()));
if (result.length) {
return this.getPagedModel(this.sortExtensions(result, options));
}
return this.extensionsWorkbenchService.queryGallery({ names: ids, source: 'queryById' }, token)
.then(pager => this.getPagedModel(pager));
}
private async queryLocal(query: Query, options: IQueryOptions): Promise<IPagedModel<IExtension>> {
let value = query.value;
if (/@builtin/i.test(value)) {
@@ -347,21 +376,6 @@ export class ExtensionsListView extends ViewletPanel {
options.sortBy = SortBy.InstallCount;
}
let value = query.value;
const idRegex = /@id:(([a-z0-9A-Z][a-z0-9\-A-Z]*)\.([a-z0-9A-Z][a-z0-9\-A-Z]*))/g;
let idMatch;
const names: string[] = [];
while ((idMatch = idRegex.exec(value)) !== null) {
const name = idMatch[1];
names.push(name);
}
if (names.length) {
return this.extensionsWorkbenchService.queryGallery({ names, source: 'queryById' }, token)
.then(pager => this.getPagedModel(pager));
}
if (ExtensionsListView.isWorkspaceRecommendedExtensionsQuery(query.value)) {
return this.getWorkspaceRecommendationsModel(query, options, token);
} else if (ExtensionsListView.isKeymapsRecommendedExtensionsQuery(query.value)) {

View File

@@ -1056,7 +1056,7 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService,
const extension = local.filter(local => areSameExtensions(local.identifier, { id: extensionId }))[0];
if (extension) {
return this.windowService.show()
return this.windowService.focusWindow()
.then(() => this.open(extension));
}
@@ -1067,7 +1067,7 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService,
const extension = result.firstPage[0];
return this.windowService.show().then(() => {
return this.windowService.focusWindow().then(() => {
return this.open(extension).then(() => {
this.notificationService.prompt(
Severity.Info,