mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 19:18:59 +01:00
Add showTextDocument(uri|file)
This commit is contained in:
@@ -282,8 +282,20 @@ export function createApiFactory(
|
||||
get visibleTextEditors() {
|
||||
return extHostEditors.getVisibleTextEditors();
|
||||
},
|
||||
showTextDocument(document: vscode.TextDocument, columnOrOptions?: vscode.ViewColumn | vscode.TextDocumentShowOptions, preserveFocus?: boolean): TPromise<vscode.TextEditor> {
|
||||
return extHostEditors.showTextDocument(document, columnOrOptions, preserveFocus);
|
||||
showTextDocument(documentOrUriOrFilename: vscode.TextDocument | vscode.Uri | string, columnOrOptions?: vscode.ViewColumn | vscode.TextDocumentShowOptions, preserveFocus?: boolean): TPromise<vscode.TextEditor> {
|
||||
let documentPromise: TPromise<vscode.TextDocument>;
|
||||
|
||||
if (typeof documentOrUriOrFilename === 'string') {
|
||||
documentPromise = workspace.openTextDocument(documentOrUriOrFilename) as TPromise<vscode.TextDocument>;
|
||||
} else if (URI.isUri(documentOrUriOrFilename)) {
|
||||
documentPromise = workspace.openTextDocument(documentOrUriOrFilename) as TPromise<vscode.TextDocument>;
|
||||
} else {
|
||||
documentPromise = TPromise.as(documentOrUriOrFilename as vscode.TextDocument);
|
||||
}
|
||||
|
||||
return documentPromise.then(document => {
|
||||
return extHostEditors.showTextDocument(document, columnOrOptions, preserveFocus);
|
||||
});
|
||||
},
|
||||
createTextEditorDecorationType(options: vscode.DecorationRenderOptions): vscode.TextEditorDecorationType {
|
||||
return extHostEditors.createTextEditorDecorationType(options);
|
||||
|
||||
@@ -234,7 +234,7 @@ export class ExtHostApiCommands {
|
||||
this._register('vscode.open', (resource: URI, column: vscode.ViewColumn) => {
|
||||
return this._commands.executeCommand('_workbench.open', [resource, typeConverters.fromViewColumn(column)]);
|
||||
}, {
|
||||
description: 'Opens the provided resource in the editor. Can be a text or binary file, or a http(s) url',
|
||||
description: 'Opens the provided resource in the editor. Can be a text or binary file, or a http(s) url. If you need more control over the options for opening a text file, use vscode.window.showTextDocument instead.',
|
||||
args: [
|
||||
{ name: 'resource', description: 'Resource to open', constraint: URI },
|
||||
{ name: 'column', description: '(optional) Column in which to open', constraint: v => v === void 0 || typeof v === 'number' }
|
||||
|
||||
Reference in New Issue
Block a user