Can no longer open image files from the git viewlet (fixes #33739)

This commit is contained in:
Benjamin Pasero
2017-09-05 18:18:49 +02:00
parent eac1f7dd7c
commit 2a936541cb
4 changed files with 39 additions and 22 deletions

View File

@@ -15,7 +15,7 @@ import * as modes from 'vs/editor/common/modes';
import { ICommandHandlerDescription } from 'vs/platform/commands/common/commands';
import { ExtHostCommands } from 'vs/workbench/api/node/extHostCommands';
import { IWorkspaceSymbolProvider } from 'vs/workbench/parts/search/common/search';
import { ITextEditorOptions } from 'vs/platform/editor/common/editor';
import { Position as EditorPosition, ITextEditorOptions } from 'vs/platform/editor/common/editor';
export class ExtHostApiCommands {
@@ -205,20 +205,11 @@ export class ExtHostApiCommands {
});
this._register('vscode.diff', (left: URI, right: URI, label: string, options?: vscode.TextDocumentShowOptions) => {
let editorOptions: ITextEditorOptions;
if (options) {
editorOptions = {
pinned: typeof options.preview === 'boolean' ? !options.preview : undefined,
preserveFocus: options.preserveFocus,
selection: typeof options.selection === 'object' ? typeConverters.fromRange(options.selection) : undefined
};
}
return this._commands.executeCommand('_workbench.diff', [
left, right,
label,
undefined,
editorOptions,
typeConverters.toTextEditorOptions(options),
options ? typeConverters.fromViewColumn(options.viewColumn) : undefined
]);
}, {
@@ -231,13 +222,29 @@ export class ExtHostApiCommands {
]
});
this._register('vscode.open', (resource: URI, column: vscode.ViewColumn) => {
return this._commands.executeCommand('_workbench.open', [resource, typeConverters.fromViewColumn(column)]);
this._register('vscode.open', (resource: URI, columnOrOptions?: vscode.ViewColumn | vscode.TextDocumentShowOptions) => {
let options: ITextEditorOptions;
let column: EditorPosition;
if (columnOrOptions) {
if (typeof columnOrOptions === 'number') {
column = typeConverters.fromViewColumn(columnOrOptions);
} else {
options = typeConverters.toTextEditorOptions(columnOrOptions);
column = typeConverters.fromViewColumn(columnOrOptions.viewColumn);
}
}
return this._commands.executeCommand('_workbench.open', [
resource,
options,
column
]);
}, {
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' }
{ name: 'columnOrOptions', description: '(optional) Either the column in which to open or editor options, see vscode.TextDocumentShowOptions', constraint: v => v === void 0 || typeof v === 'number' || typeof v === 'object' }
]
});
}