Skip to content

Commit

Permalink
fix #51358
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Jun 11, 2018
1 parent f0a8231 commit 799f31b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
20 changes: 12 additions & 8 deletions src/vs/workbench/api/electron-browser/mainThreadEditors.ts
Expand Up @@ -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 {

Expand Down Expand Up @@ -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);
Expand Down
9 changes: 0 additions & 9 deletions src/vs/workbench/services/editor/browser/editorService.ts
Expand Up @@ -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 = <IResourceInput>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 = <IResourceEditor>editor;
const typedInput = this.createInput(textInput);
Expand Down

0 comments on commit 799f31b

Please sign in to comment.