提交 8385255c 编写于 作者: J Joao Moreno

ext install pub.name

fixes #37033
上级 aaffe688
......@@ -10,6 +10,7 @@ import { QuickOpenEntry, QuickOpenModel } from 'vs/base/parts/quickopen/browser/
import { QuickOpenHandler } from 'vs/workbench/browser/quickopen';
import { IExtensionsViewlet, VIEWLET_ID } from 'vs/workbench/parts/extensions/common/extensions';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { IExtensionGalleryService, IExtensionManagementService } from 'vs/platform/extensionManagement/common/extensionManagement';
class SimpleEntry extends QuickOpenEntry {
......@@ -71,11 +72,41 @@ export class GalleryExtensionsHandler extends QuickOpenHandler {
public static readonly ID = 'workbench.picker.gallery';
constructor( @IViewletService private viewletService: IViewletService) {
constructor(
@IViewletService private viewletService: IViewletService,
@IExtensionGalleryService private galleryService: IExtensionGalleryService,
@IExtensionManagementService private extensionsService: IExtensionManagementService
) {
super();
}
getResults(text: string): TPromise<IModel<any>> {
if (/\./.test(text)) {
return this.galleryService.query({ names: [text], pageSize: 1 })
.then(galleryResult => {
const entries: SimpleEntry[] = [];
const galleryExtension = galleryResult.firstPage[0];
if (!galleryExtension) {
const label = nls.localize('notfound', "Extension '{0}' not found in the Marketplace.", text);
entries.push(new SimpleEntry(label, () => null));
} else {
const label = nls.localize('install', "Press Enter to install '{0}' from the Marketplace.", text);
const action = () => {
return this.viewletService.openViewlet(VIEWLET_ID, true)
.then(viewlet => viewlet as IExtensionsViewlet)
.then(viewlet => viewlet.search(`@id:${text}`))
.done(() => this.extensionsService.installFromGallery(galleryExtension));
};
entries.push(new SimpleEntry(label, action));
}
return new QuickOpenModel(entries);
});
}
const entries: SimpleEntry[] = [];
if (text) {
......
......@@ -190,6 +190,15 @@ export class ExtensionsListView extends ViewsViewletPanel {
return new PagedModel(result);
}
const idMatch = /@id:([a-z0-9][a-z0-9\-]*\.[a-z0-9][a-z0-9\-]*)/.exec(value);
if (idMatch) {
const name = idMatch[1];
return this.extensionsWorkbenchService.queryGallery({ names: [name] })
.then(pager => new PagedModel(pager));
}
if (/@outdated/i.test(value)) {
value = value.replace(/@outdated/g, '').trim().toLowerCase();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册