From 464637dbe68fb08775b5beb8baba1a12043a7ff9 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Thu, 14 Apr 2016 15:04:33 +0200 Subject: [PATCH] vscode.previewHtml accept URI or string --- src/vs/workbench/api/node/extHostApiCommands.ts | 4 ++-- src/vs/workbench/parts/html/browser/html.contribution.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/vs/workbench/api/node/extHostApiCommands.ts b/src/vs/workbench/api/node/extHostApiCommands.ts index a59299c84e2..ae306f0fa56 100644 --- a/src/vs/workbench/api/node/extHostApiCommands.ts +++ b/src/vs/workbench/api/node/extHostApiCommands.ts @@ -156,9 +156,9 @@ class ExtHostApiCommands { typeof position === 'number' ? typeConverters.fromViewColumn(position) : void 0); }, { - description: 'Preview an html document.', + description: 'Render the html of the resource in an editor view.', args: [ - { name: 'uri', description: 'Uri of the document to preview.', constraint: URI }, + { name: 'uri', description: 'Uri of the resource to preview.', constraint: value => value instanceof URI || typeof value === 'string' }, { name: 'column', description: '(optional) Column in which to preview.' }, ] }); diff --git a/src/vs/workbench/parts/html/browser/html.contribution.ts b/src/vs/workbench/parts/html/browser/html.contribution.ts index 65ea8acda8c..ccb1e10715c 100644 --- a/src/vs/workbench/parts/html/browser/html.contribution.ts +++ b/src/vs/workbench/parts/html/browser/html.contribution.ts @@ -28,11 +28,11 @@ import {SyncDescriptor} from 'vs/platform/instantiation/common/descriptors'; KeybindingsRegistry.registerCommandDesc({ id: '_workbench.previewHtml', weight: KeybindingsRegistry.WEIGHT.workbenchContrib(0), - handler(accessor: ServicesAccessor, args: [URI, EditorPosition]) { + handler(accessor: ServicesAccessor, args: [URI|string, EditorPosition]) { let [resource, position] = args; - let name = resource.fsPath; - let input = accessor.get(IInstantiationService).createInstance(HtmlInput, name, undefined, resource); + let uri = resource instanceof URI ? resource : URI.parse(resource); + let input = accessor.get(IInstantiationService).createInstance(HtmlInput, uri.fsPath, undefined, uri); return accessor.get(IWorkbenchEditorService).openEditor(input, null, position) .then(editor => true);