open extension from URI
This commit is contained in:
parent
42832a3a68
commit
b837ad083b
|
@ -30,6 +30,8 @@ import { IExtensionManagementService, IExtensionGalleryService, SortBy } from 'v
|
|||
import { ExtensionsInput } from './extensionsInput';
|
||||
import { IProgressService } from 'vs/platform/progress/common/progress';
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IURLService } from 'vs/platform/url/common/url';
|
||||
import URI from 'vs/base/common/uri';
|
||||
|
||||
export class ExtensionsViewlet extends Viewlet implements IExtensionsViewlet {
|
||||
|
||||
|
@ -52,10 +54,14 @@ export class ExtensionsViewlet extends Viewlet implements IExtensionsViewlet {
|
|||
@IProgressService private progressService: IProgressService,
|
||||
@IInstantiationService private instantiationService: IInstantiationService,
|
||||
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
|
||||
@IExtensionsWorkbenchService private extensionsWorkbenchService: IExtensionsWorkbenchService
|
||||
@IExtensionsWorkbenchService private extensionsWorkbenchService: IExtensionsWorkbenchService,
|
||||
@IURLService urlService: IURLService
|
||||
) {
|
||||
super(VIEWLET_ID, telemetryService);
|
||||
this.searchDelayer = new ThrottledDelayer(500);
|
||||
|
||||
const onOpenExtensionUrl = filterEvent(urlService.onOpenURL, uri => /^extension/.test(uri.path));
|
||||
onOpenExtensionUrl(this.onOpenExtensionUrl, this, this.disposables);
|
||||
}
|
||||
|
||||
create(parent: Builder): TPromise<void> {
|
||||
|
@ -95,7 +101,7 @@ export class ExtensionsViewlet extends Viewlet implements IExtensionsViewlet {
|
|||
onInput(() => this.triggerSearch(), null, this.disposables);
|
||||
|
||||
const onSelectedExtension = filterEvent(mapEvent(this.list.onSelectionChange, e => e.elements[0]), e => !!e);
|
||||
onSelectedExtension(this.onExtensionSelected, this, this.disposables);
|
||||
onSelectedExtension(this.openExtension, this, this.disposables);
|
||||
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
@ -191,7 +197,7 @@ export class ExtensionsViewlet extends Viewlet implements IExtensionsViewlet {
|
|||
});
|
||||
}
|
||||
|
||||
private onExtensionSelected(extension: IExtension): void {
|
||||
private openExtension(extension: IExtension): void {
|
||||
this.editorService.openEditor(this.instantiationService.createInstance(ExtensionsInput, extension))
|
||||
.done(null, onUnexpectedError);
|
||||
}
|
||||
|
@ -225,6 +231,26 @@ export class ExtensionsViewlet extends Viewlet implements IExtensionsViewlet {
|
|||
this.list.reveal(this.list.getFocus()[0]);
|
||||
}
|
||||
|
||||
private onOpenExtensionUrl(uri: URI): void {
|
||||
const match = /^extension\/([^/]+)$/.exec(uri.path);
|
||||
|
||||
if (!match) {
|
||||
return;
|
||||
}
|
||||
|
||||
const extensionId = match[1];
|
||||
|
||||
this.extensionsWorkbenchService.queryGallery({ names: [extensionId] })
|
||||
.done(result => {
|
||||
if (result.total < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
const extension = result.firstPage[0];
|
||||
this.openExtension(extension);
|
||||
});
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.disposables = dispose(this.disposables);
|
||||
super.dispose();
|
||||
|
|
|
@ -17,7 +17,6 @@ import { IWorkspaceContextService } from 'vs/workbench/services/workspace/common
|
|||
import { IActivityService, ProgressBadge, NumberBadge } from 'vs/workbench/services/activity/common/activityService';
|
||||
import { ReloadWindowAction } from 'vs/workbench/electron-browser/actions';
|
||||
import { ipcRenderer as ipc } from 'electron';
|
||||
import { IURLService } from 'vs/platform/url/common/url';
|
||||
|
||||
interface IInstallExtensionsRequest {
|
||||
extensionsToInstall: string[];
|
||||
|
@ -32,8 +31,7 @@ export class ExtensionsWorkbenchExtension implements IWorkbenchContribution {
|
|||
@IMessageService private messageService: IMessageService,
|
||||
@IWorkspaceContextService contextService: IWorkspaceContextService,
|
||||
@IExtensionTipsService extenstionTips: IExtensionTipsService, // this is to eagerly start the service
|
||||
@IExtensionGalleryService galleryService: IExtensionGalleryService,
|
||||
@IURLService urlService: IURLService
|
||||
@IExtensionGalleryService galleryService: IExtensionGalleryService
|
||||
) {
|
||||
this.registerListeners();
|
||||
|
||||
|
@ -43,8 +41,6 @@ export class ExtensionsWorkbenchExtension implements IWorkbenchContribution {
|
|||
this.install(options.extensionsToInstall).done(null, onUnexpectedError);
|
||||
}
|
||||
|
||||
urlService.onOpenURL(url => console.log(url));
|
||||
|
||||
//actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(InstallExtensionAction, InstallExtensionAction.ID, InstallExtensionAction.LABEL), 'Extensions: Install Extension', ExtensionsLabel);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue