From 799f31b5ff6e668b07858a2d82029b7204c752db Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Mon, 11 Jun 2018 11:46:05 +0200 Subject: [PATCH] fix #51358 --- .../api/electron-browser/mainThreadEditors.ts | 20 +++++++++++-------- .../services/editor/browser/editorService.ts | 9 --------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/vs/workbench/api/electron-browser/mainThreadEditors.ts b/src/vs/workbench/api/electron-browser/mainThreadEditors.ts index b1a55b0dd2b..2e3c3bbf630 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadEditors.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadEditors.ts @@ -27,7 +27,6 @@ import { ExtHostContext, ExtHostEditorsShape, IExtHostContext, ITextDocumentShow import { MainThreadDocumentsAndEditors } from './mainThreadDocumentsAndEditors'; import { MainThreadTextEditor } from './mainThreadEditor'; import { IOpenerService } from 'vs/platform/opener/common/opener'; -import { IFileService } from 'vs/platform/files/common/files'; export class MainThreadTextEditors implements MainThreadTextEditorsShape { @@ -253,19 +252,24 @@ CommandsRegistry.registerCommand('_workbench.open', function (accessor: Services const editorService = accessor.get(IEditorService); const editorGroupService = accessor.get(IEditorGroupsService); const openerService = accessor.get(IOpenerService); - const fileService = accessor.get(IFileService); const [resource, options, position] = args; - if (fileService.canHandleResource(resource)) { - return editorService.openEditor({ resource, options }, viewColumnToEditorGroup(editorGroupService, position)).then(() => void 0); - } else { - // http://, https://, command:id - //todo@ben make this proper - return openerService.open(resource).then(_ => void 0); + if (options || typeof position === 'number') { + // use editor options or editor view column as a hint to use the editor service for opening + return editorService.openEditor({ resource, options }, viewColumnToEditorGroup(editorGroupService, position)).then(_ => void 0); } + + if (resource && resource.scheme === 'command') { + // do not allow to execute commands from here + return TPromise.as(void 0); + } + + // finally, delegate to opener service + return openerService.open(resource).then(_ => void 0); }); + CommandsRegistry.registerCommand('_workbench.diff', function (accessor: ServicesAccessor, args: [URI, URI, string, string, IEditorOptions, EditorViewColumn]) { const editorService = accessor.get(IEditorService); const editorGroupService = accessor.get(IEditorGroupsService); diff --git a/src/vs/workbench/services/editor/browser/editorService.ts b/src/vs/workbench/services/editor/browser/editorService.ts index d5ba813c5c7..33eb4fc67bb 100644 --- a/src/vs/workbench/services/editor/browser/editorService.ts +++ b/src/vs/workbench/services/editor/browser/editorService.ts @@ -235,15 +235,6 @@ export class EditorService extends Disposable implements EditorServiceImpl { return this.doOpenEditor(targetGroup, editor, editorOptions); } - // Throw error for well known foreign resources (such as a http link) (TODO@ben remove me after this has been adopted) - const resourceInput = editor; - if (resourceInput.resource instanceof URI) { - const schema = resourceInput.resource.scheme; - if (schema === Schemas.http || schema === Schemas.https) { - return TPromise.wrapError(new Error('Invalid scheme http/https to open resource as editor. Use IOpenerService instead.')); - } - } - // Untyped Text Editor Support const textInput = editor; const typedInput = this.createInput(textInput);