提交 a9c18951 编写于 作者: J Johannes Rieken

allow to provide ViewColumn with 'vscode.previewHtml' command

上级 eb2daf67
......@@ -49,7 +49,7 @@ suite("commands namespace tests", () => {
let virtualDocumentUri = Uri.parse('speciale://authority/path')
return commands.executeCommand('workbench.html.preview', virtualDocumentUri).then(success => {
return commands.executeCommand('vscode.previewHtml', virtualDocumentUri).then(success => {
assert.ok(success);
registration.dispose();
});
......
......@@ -145,6 +145,19 @@ class ExtHostApiCommands {
],
returns: 'A promise that resolves to an array of TextEdits.'
});
this._register('vscode.previewHtml', (uri: URI, position?: vscode.ViewColumn) => {
return this._commands.executeCommand('_workbench.previewHtml', uri,
typeof position === 'number' ? typeConverters.fromViewColumn(position) : void 0);
}, {
description: 'Preview an html document.',
args: [
{ name: 'uri', description: 'Uri of the document to preview.', constraint: URI },
{ name: 'column', description: '(optional) Column in which to preview.' },
]
});
}
// --- command impl
......
......@@ -9,6 +9,7 @@ import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegi
import {IInstantiationService, ServicesAccessor} from 'vs/platform/instantiation/common/instantiation';
import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService';
import URI from 'vs/base/common/uri';
import {Position as EditorPosition} from 'vs/platform/editor/common/editor';
import {HtmlInput} from '../common/htmlInput';
import {HtmlPreviewPart} from 'vs/workbench/parts/html/browser/htmlPreviewPart';
import {Registry} from 'vs/platform/platform';
......@@ -27,19 +28,15 @@ import {SyncDescriptor} from 'vs/platform/instantiation/common/descriptors';
// --- Register Commands
KeybindingsRegistry.registerCommandDesc({
id: 'workbench.html.preview',
id: '_workbench.previewHtml',
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(0),
description: {
description: 'Preview an html document.',
args: [{ name: 'uri', description: 'Uri of the document to preview.', constraint: URI }]
},
handler(accessor: ServicesAccessor, args: [URI]) {
handler(accessor: ServicesAccessor, args: [URI, EditorPosition]) {
let [resource] = args;
let [resource, position] = args;
let name = resource.fsPath;
let input = accessor.get(IInstantiationService).createInstance(HtmlInput, name, undefined, resource);
return accessor.get(IWorkbenchEditorService).openEditor(input)
return accessor.get(IWorkbenchEditorService).openEditor(input, null, position)
.then(editor => true);
},
context: undefined,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册