From adf06c525694a38aefaddc7dfb176c018188e70e Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Wed, 6 Jul 2016 12:18:28 +0200 Subject: [PATCH] Allow to use editor options interface without creating EditorOptions instance (fixes #6604) --- .../workbench/browser/actions/openSettings.ts | 3 +-- .../browser/parts/editor/editorActions.ts | 4 ++-- .../parts/editor/sideBySideEditorControl.ts | 9 ++++----- .../browser/parts/editor/tabsTitleControl.ts | 10 +++++----- .../parts/quickopen/quickOpenController.ts | 4 ++-- src/vs/workbench/common/editor.ts | 20 ++++--------------- .../debug/electron-browser/debugService.ts | 2 +- .../parts/files/browser/fileActions.ts | 4 ++-- .../parts/files/browser/fileTracker.ts | 19 ++++-------------- .../parts/files/browser/views/explorerView.ts | 3 +-- .../files/browser/views/explorerViewer.ts | 8 +++----- .../files/browser/views/openEditorsViewer.ts | 4 ++-- .../services/editor/browser/editorService.ts | 20 ++++++++++++++++--- 13 files changed, 48 insertions(+), 62 deletions(-) diff --git a/src/vs/workbench/browser/actions/openSettings.ts b/src/vs/workbench/browser/actions/openSettings.ts index 68c72f3f08f..6b6265cc052 100644 --- a/src/vs/workbench/browser/actions/openSettings.ts +++ b/src/vs/workbench/browser/actions/openSettings.ts @@ -12,7 +12,6 @@ import labels = require('vs/base/common/labels'); import {Registry} from 'vs/platform/platform'; import {Action} from 'vs/base/common/actions'; import strings = require('vs/base/common/strings'); -import {EditorOptions} from 'vs/workbench/common/editor'; import {IWorkbenchActionRegistry, Extensions} from 'vs/workbench/common/actionRegistry'; import {StringEditorInput} from 'vs/workbench/common/editor/stringEditorInput'; import {getDefaultValuesContent} from 'vs/platform/configuration/common/model'; @@ -140,7 +139,7 @@ export class OpenGlobalSettingsAction extends BaseOpenSettingsAction { let editorCount = this.editorService.getVisibleEditors().length; return this.editorService.createInput({ resource: this.contextService.toResource('.vscode/settings.json') }).then((typedInput) => { - return this.editorService.openEditor(typedInput, EditorOptions.create({ pinned: true }), editorCount === 2 ? Position.RIGHT : editorCount === 1 ? Position.CENTER : void 0); + return this.editorService.openEditor(typedInput, { pinned: true }, editorCount === 2 ? Position.RIGHT : editorCount === 1 ? Position.CENTER : void 0); }); }) ] diff --git a/src/vs/workbench/browser/parts/editor/editorActions.ts b/src/vs/workbench/browser/parts/editor/editorActions.ts index 4b831fde6b2..2fb95f5625c 100644 --- a/src/vs/workbench/browser/parts/editor/editorActions.ts +++ b/src/vs/workbench/browser/parts/editor/editorActions.ts @@ -236,7 +236,7 @@ export abstract class BaseFocusSideGroupAction extends Action { // For now only support to open files from history to the side if (!!getUntitledOrFileResource(input)) { - return this.editorService.openEditor(input, EditorOptions.create({ pinned: true }), this.getTargetEditorSide()); + return this.editorService.openEditor(input, { pinned: true }, this.getTargetEditorSide()); } } } @@ -909,7 +909,7 @@ export class ReopenClosedEditorAction extends Action { } if (lastClosedEditor) { - this.editorService.openEditor(lastClosedEditor, EditorOptions.create({ pinned: true })); + this.editorService.openEditor(lastClosedEditor, { pinned: true }); } return TPromise.as(false); diff --git a/src/vs/workbench/browser/parts/editor/sideBySideEditorControl.ts b/src/vs/workbench/browser/parts/editor/sideBySideEditorControl.ts index b0e50c7d110..47088db628f 100644 --- a/src/vs/workbench/browser/parts/editor/sideBySideEditorControl.ts +++ b/src/vs/workbench/browser/parts/editor/sideBySideEditorControl.ts @@ -33,7 +33,7 @@ import {IDisposable, dispose} from 'vs/base/common/lifecycle'; import {TabsTitleControl} from 'vs/workbench/browser/parts/editor/tabsTitleControl'; import {TitleControl} from 'vs/workbench/browser/parts/editor/titleControl'; import {NoTabsTitleControl} from 'vs/workbench/browser/parts/editor/noTabsTitleControl'; -import {IEditorStacksModel, IStacksModelChangeEvent, IWorkbenchEditorConfiguration, EditorOptions} from 'vs/workbench/common/editor'; +import {IEditorStacksModel, IStacksModelChangeEvent, IWorkbenchEditorConfiguration} from 'vs/workbench/common/editor'; import {ITitleAreaControl} from 'vs/workbench/browser/parts/editor/titleControl'; import {extractResources} from 'vs/base/browser/dnd'; @@ -804,7 +804,6 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti const splitEditor = (typeof splitTo === 'number'); // TODO@Ben ugly split code should benefit from empty group support once available! const freeGroup = (stacks.groups.length === 1) ? Position.CENTER : Position.RIGHT; - const pinned = EditorOptions.create({ pinned: true }); // Check for transfer from title control const draggedEditor = TitleControl.getDraggedEditor(); @@ -814,13 +813,13 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti // Copy editor to new location if (isCopy) { if (splitEditor) { - editorService.openEditor(draggedEditor.editor, pinned, freeGroup).then(() => { + editorService.openEditor(draggedEditor.editor, { pinned: true }, freeGroup).then(() => { if (splitTo !== freeGroup) { groupService.moveGroup(freeGroup, splitTo); } }).done(null, errors.onUnexpectedError); } else { - editorService.openEditor(draggedEditor.editor, pinned, position).done(null, errors.onUnexpectedError); + editorService.openEditor(draggedEditor.editor, { pinned: true }, position).done(null, errors.onUnexpectedError); } } @@ -831,7 +830,7 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti if (draggedEditor.group.count === 1) { groupService.moveGroup(sourcePosition, splitTo); } else { - editorService.openEditor(draggedEditor.editor, pinned, freeGroup).then(() => { + editorService.openEditor(draggedEditor.editor, { pinned: true }, freeGroup).then(() => { if (splitTo !== freeGroup) { groupService.moveGroup(freeGroup, splitTo); } diff --git a/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts b/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts index 133271af37b..aecd0a70dfd 100644 --- a/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts +++ b/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts @@ -15,7 +15,7 @@ import DOM = require('vs/base/browser/dom'); import {isMacintosh} from 'vs/base/common/platform'; import {MIME_BINARY} from 'vs/base/common/mime'; import {Position} from 'vs/platform/editor/common/editor'; -import {IEditorGroup, IEditorIdentifier, asFileEditorInput, EditorOptions} from 'vs/workbench/common/editor'; +import {IEditorGroup, IEditorIdentifier, asFileEditorInput} from 'vs/workbench/common/editor'; import {ToolBar} from 'vs/base/browser/ui/toolbar/toolbar'; import {StandardKeyboardEvent} from 'vs/base/browser/keyboardEvent'; import {CommonKeybindings as Kb, KeyCode} from 'vs/base/common/keyCodes'; @@ -97,7 +97,7 @@ export class TabsTitleControl extends TitleControl { if (target instanceof HTMLElement && target.className.indexOf('tabs-container') === 0) { DOM.EventHelper.stop(e); - return this.editorService.openEditor(this.untitledEditorService.createOrGet(), EditorOptions.create({ pinned: true })); // untitled are always pinned + return this.editorService.openEditor(this.untitledEditorService.createOrGet(), { pinned: true }); // untitled are always pinned } })); @@ -165,7 +165,7 @@ export class TabsTitleControl extends TitleControl { // Copy: just open editor at target index else { - this.editorService.openEditor(draggedEditor.editor, EditorOptions.create({ pinned: true, index: targetIndex }), targetPosition).done(null, errors.onUnexpectedError); + this.editorService.openEditor(draggedEditor.editor, { pinned: true, index: targetIndex }, targetPosition).done(null, errors.onUnexpectedError); } this.onEditorDragEnd(); @@ -433,7 +433,7 @@ export class TabsTitleControl extends TitleControl { const target = group.getEditor(targetIndex); if (target) { handled = true; - this.editorService.openEditor(target, EditorOptions.create({ preserveFocus: true }), position).done(null, errors.onUnexpectedError); + this.editorService.openEditor(target, { preserveFocus: true }, position).done(null, errors.onUnexpectedError); (this.tabsContainer.childNodes[targetIndex]).focus(); } } @@ -508,7 +508,7 @@ export class TabsTitleControl extends TitleControl { // Copy: just open editor at target index else { - this.editorService.openEditor(draggedEditor.editor, EditorOptions.create({ pinned: true, index: targetIndex }), targetPosition).done(null, errors.onUnexpectedError); + this.editorService.openEditor(draggedEditor.editor, { pinned: true, index: targetIndex }, targetPosition).done(null, errors.onUnexpectedError); } this.onEditorDragEnd(); diff --git a/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts b/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts index e600cebf6a8..39a456a8aac 100644 --- a/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts +++ b/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts @@ -22,7 +22,7 @@ import {ITree, IElementCallback} from 'vs/base/parts/tree/browser/tree'; import labels = require('vs/base/common/labels'); import paths = require('vs/base/common/paths'); import {Registry} from 'vs/platform/platform'; -import {EditorInput, EditorOptions, getUntitledOrFileResource, IWorkbenchEditorConfiguration} from 'vs/workbench/common/editor'; +import {EditorInput, getUntitledOrFileResource, IWorkbenchEditorConfiguration} from 'vs/workbench/common/editor'; import {WorkbenchComponent} from 'vs/workbench/common/component'; import Event, {Emitter} from 'vs/base/common/event'; import {Identifiers} from 'vs/workbench/common/constants'; @@ -1025,7 +1025,7 @@ export class EditorHistoryEntry extends EditorQuickOpenEntry { const sideBySide = !context.quickNavigateConfiguration && context.keymods.indexOf(KeyMod.CtrlCmd) >= 0; const pinned = !this.configurationService.getConfiguration().workbench.editor.enablePreviewFromQuickOpen; - this.editorService.openEditor(this.input, EditorOptions.create({ pinned }), sideBySide).done(null, errors.onUnexpectedError); + this.editorService.openEditor(this.input, { pinned }, sideBySide).done(null, errors.onUnexpectedError); return true; } diff --git a/src/vs/workbench/common/editor.ts b/src/vs/workbench/common/editor.ts index cefbd9e34d4..f3b73db2596 100644 --- a/src/vs/workbench/common/editor.ts +++ b/src/vs/workbench/common/editor.ts @@ -9,8 +9,8 @@ import {EventEmitter} from 'vs/base/common/eventEmitter'; import Event, {Emitter} from 'vs/base/common/event'; import types = require('vs/base/common/types'); import URI from 'vs/base/common/uri'; -import {IEditor, IEditorViewState, IRange} from 'vs/editor/common/editorCommon'; -import {IEditorInput, IEditorModel, IEditorOptions, IResourceInput, Position} from 'vs/platform/editor/common/editor'; +import {IEditor, IEditorViewState} from 'vs/editor/common/editorCommon'; +import {IEditorInput, IEditorModel, IEditorOptions, IEditorOptionsBag, ITextEditorOptions, IResourceInput, Position} from 'vs/platform/editor/common/editor'; import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace'; import {Event as BaseEvent} from 'vs/base/common/events'; import {IEditorGroupService} from 'vs/workbench/services/group/common/groupService'; @@ -332,13 +332,7 @@ export class EditorOptions implements IEditorOptions { /** * Helper to create EditorOptions inline. */ - public static create(settings: { - preserveFocus?: boolean; - forceOpen?: boolean; - pinned?: boolean, - index?: number, - inactive?: boolean - }): EditorOptions { + public static create(settings: IEditorOptionsBag): EditorOptions { let options = new EditorOptions(); options.preserveFocus = settings.preserveFocus; options.forceOpen = settings.forceOpen; @@ -439,13 +433,7 @@ export class TextEditorOptions extends EditorOptions { /** * Helper to create TextEditorOptions inline. */ - public static create(settings: { - preserveFocus?: boolean; - forceOpen?: boolean; - pinned?: boolean; - index?: number; - selection?: IRange - }): TextEditorOptions { + public static create(settings: ITextEditorOptions): TextEditorOptions { let options = new TextEditorOptions(); options.preserveFocus = settings.preserveFocus; options.forceOpen = settings.forceOpen; diff --git a/src/vs/workbench/parts/debug/electron-browser/debugService.ts b/src/vs/workbench/parts/debug/electron-browser/debugService.ts index d59b0b69fe3..d6ac1123d56 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugService.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugService.ts @@ -854,7 +854,7 @@ export class DebugService implements debug.IDebugService { this.model.sourceIsUnavailable(source); const editorInput = this.getDebugStringEditorInput(source, nls.localize('debugSourceNotAvailable', "Source {0} is not available.", source.uri.fsPath), 'text/plain'); - return this.editorService.openEditor(editorInput, wbeditorcommon.TextEditorOptions.create({ preserveFocus: true }), sideBySide); + return this.editorService.openEditor(editorInput, { preserveFocus: true }, sideBySide); } public getConfigurationManager(): debug.IConfigurationManager { diff --git a/src/vs/workbench/parts/files/browser/fileActions.ts b/src/vs/workbench/parts/files/browser/fileActions.ts index 88888ba3990..801b1715bf1 100644 --- a/src/vs/workbench/parts/files/browser/fileActions.ts +++ b/src/vs/workbench/parts/files/browser/fileActions.ts @@ -28,7 +28,7 @@ import {EventType as WorkbenchEventType} from 'vs/workbench/common/events'; import {LocalFileChangeEvent, VIEWLET_ID, ITextFileService, TextFileChangeEvent, EventType as FileEventType} from 'vs/workbench/parts/files/common/files'; import {IFileService, IFileStat, IImportResult} from 'vs/platform/files/common/files'; import {DiffEditorInput, toDiffLabel} from 'vs/workbench/common/editor/diffEditorInput'; -import {asFileEditorInput, getUntitledOrFileResource, EditorOptions, UntitledEditorInput, ConfirmResult, IEditorIdentifier} from 'vs/workbench/common/editor'; +import {asFileEditorInput, getUntitledOrFileResource, UntitledEditorInput, ConfirmResult, IEditorIdentifier} from 'vs/workbench/common/editor'; import {FileEditorInput} from 'vs/workbench/parts/files/browser/editors/fileEditorInput'; import {FileStat, NewStatPlaceholder} from 'vs/workbench/parts/files/common/explorerViewModel'; import {ExplorerView} from 'vs/workbench/parts/files/browser/views/explorerView'; @@ -566,7 +566,7 @@ export class GlobalNewUntitledFileAction extends Action { public run(): TPromise { let input = this.untitledEditorService.createOrGet(); - return this.editorService.openEditor(input, EditorOptions.create({ pinned: true })); // untitled are always pinned + return this.editorService.openEditor(input, { pinned: true }); // untitled are always pinned } } diff --git a/src/vs/workbench/parts/files/browser/fileTracker.ts b/src/vs/workbench/parts/files/browser/fileTracker.ts index 30494df899f..361e67f6813 100644 --- a/src/vs/workbench/parts/files/browser/fileTracker.ts +++ b/src/vs/workbench/parts/files/browser/fileTracker.ts @@ -12,7 +12,7 @@ import URI from 'vs/base/common/uri'; import paths = require('vs/base/common/paths'); import arrays = require('vs/base/common/arrays'); import {DiffEditorInput} from 'vs/workbench/common/editor/diffEditorInput'; -import {EditorInput, EditorOptions, IEditorStacksModel} from 'vs/workbench/common/editor'; +import {EditorInput, IEditorStacksModel} from 'vs/workbench/common/editor'; import {Position} from 'vs/platform/editor/common/editor'; import {BaseEditor} from 'vs/workbench/browser/parts/editor/baseEditor'; import {BaseTextEditor} from 'vs/workbench/browser/parts/editor/textEditor'; @@ -250,11 +250,7 @@ export class FileTracker implements IWorkbenchContribution { // Binary file: always update else if (editor.getId() === BINARY_FILE_EDITOR_ID) { - let editorOptions = new EditorOptions(); - editorOptions.forceOpen = true; - editorOptions.preserveFocus = true; - - this.editorService.openEditor(editor.input, editorOptions, editor.position).done(null, errors.onUnexpectedError); + this.editorService.openEditor(editor.input, { forceOpen: true, preserveFocus: true }, editor.position).done(null, errors.onUnexpectedError); } } } @@ -316,17 +312,10 @@ export class FileTracker implements IWorkbenchContribution { reopenFileResource = URI.file(paths.join(newResource.fsPath, inputResource.fsPath.substr(index + oldResource.fsPath.length + 1))); // update the path by changing the old path value to the new one } - let editorInput: EditorInput; - - let editorOptions = new EditorOptions(); - editorOptions.preserveFocus = true; - editorOptions.pinned = group.isPinned(input); - editorOptions.index = group.indexOf(input); - // Reopen File Input if (input instanceof FileEditorInput) { - editorInput = this.instantiationService.createInstance(FileEditorInput, reopenFileResource, mimeHint || MIME_UNKNOWN, void 0); - this.editorService.openEditor(editorInput, editorOptions, editor.position).done(null, errors.onUnexpectedError); + const editorInput = this.instantiationService.createInstance(FileEditorInput, reopenFileResource, mimeHint || MIME_UNKNOWN, void 0); + this.editorService.openEditor(editorInput, { preserveFocus: true, pinned: group.isPinned(input), index: group.indexOf(input) }, editor.position).done(null, errors.onUnexpectedError); } } } diff --git a/src/vs/workbench/parts/files/browser/views/explorerView.ts b/src/vs/workbench/parts/files/browser/views/explorerView.ts index e8eb8a93fd8..02e5757b66d 100644 --- a/src/vs/workbench/parts/files/browser/views/explorerView.ts +++ b/src/vs/workbench/parts/files/browser/views/explorerView.ts @@ -16,7 +16,6 @@ import {Action, IActionRunner, IAction} from 'vs/base/common/actions'; import {prepareActions} from 'vs/workbench/browser/actionBarRegistry'; import {ITree} from 'vs/base/parts/tree/browser/tree'; import {Tree} from 'vs/base/parts/tree/browser/treeImpl'; -import {EditorOptions} from 'vs/workbench/common/editor'; import {LocalFileChangeEvent, IFilesConfiguration} from 'vs/workbench/parts/files/common/files'; import {IFileStat, IResolveFileOptions, FileChangeType, FileChangesEvent, IFileChange, EventType as FileEventType, IFileService} from 'vs/platform/files/common/files'; import {FileImportedEvent, RefreshViewExplorerAction, NewFolderAction, NewFileAction} from 'vs/workbench/parts/files/browser/fileActions'; @@ -308,7 +307,7 @@ export class ExplorerView extends CollapsibleViewletView { } // Otherwise open in active slot - return this.editorService.openEditor(input, keepFocus ? EditorOptions.create({ preserveFocus: true }) : void 0); + return this.editorService.openEditor(input, keepFocus ? { preserveFocus: true } : void 0); } private getActiveEditorInputResource(): URI { diff --git a/src/vs/workbench/parts/files/browser/views/explorerViewer.ts b/src/vs/workbench/parts/files/browser/views/explorerViewer.ts index 9b49355866d..b6120ab61fb 100644 --- a/src/vs/workbench/parts/files/browser/views/explorerViewer.ts +++ b/src/vs/workbench/parts/files/browser/views/explorerViewer.ts @@ -27,7 +27,7 @@ import {LocalFileChangeEvent, IFilesConfiguration, ITextFileService} from 'vs/wo import {IFileOperationResult, FileOperationResult, IFileStat, IFileService} from 'vs/platform/files/common/files'; import {FileEditorInput} from 'vs/workbench/parts/files/browser/editors/fileEditorInput'; import {DuplicateFileAction, ImportFileAction, PasteFileAction, keybindingForAction, IEditableData, IFileViewletState} from 'vs/workbench/parts/files/browser/fileActions'; -import {EditorOptions, ConfirmResult} from 'vs/workbench/common/editor'; +import {ConfirmResult} from 'vs/workbench/common/editor'; import {IDataSource, ITree, IElementCallback, IAccessibilityProvider, IRenderer, ContextMenuEvent, ISorter, IFilter, IDragAndDrop, IDragAndDropData, IDragOverReaction, DRAG_OVER_ACCEPT_BUBBLE_DOWN, DRAG_OVER_ACCEPT_BUBBLE_DOWN_COPY, DRAG_OVER_ACCEPT_BUBBLE_UP, DRAG_OVER_ACCEPT_BUBBLE_UP_COPY, DRAG_OVER_REJECT} from 'vs/base/parts/tree/browser/tree'; import labels = require('vs/base/common/labels'); import {DesktopDragAndDropData, ExternalElementsDragAndDropData} from 'vs/base/parts/tree/browser/treeDnd'; @@ -593,12 +593,10 @@ export class FileController extends DefaultController { private openEditor(stat: FileStat, preserveFocus: boolean, sideBySide: boolean, pinned = false): void { if (stat && !stat.isDirectory) { - let editorInput = this.instantiationService.createInstance(FileEditorInput, stat.resource, stat.mime, void 0); - let editorOptions = EditorOptions.create({ preserveFocus, pinned }); - this.telemetryService.publicLog('workbenchActionExecuted', { id: 'workbench.files.openFile', from: 'explorer' }); - this.editorService.openEditor(editorInput, editorOptions, sideBySide).done(null, errors.onUnexpectedError); + const editorInput = this.instantiationService.createInstance(FileEditorInput, stat.resource, stat.mime, void 0); + this.editorService.openEditor(editorInput, { preserveFocus, pinned }, sideBySide).done(null, errors.onUnexpectedError); } } diff --git a/src/vs/workbench/parts/files/browser/views/openEditorsViewer.ts b/src/vs/workbench/parts/files/browser/views/openEditorsViewer.ts index 89ccef4c629..a72aab76589 100644 --- a/src/vs/workbench/parts/files/browser/views/openEditorsViewer.ts +++ b/src/vs/workbench/parts/files/browser/views/openEditorsViewer.ts @@ -23,7 +23,7 @@ import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry'; import {IEditorGroupService} from 'vs/workbench/services/group/common/groupService'; import {IContextMenuService} from 'vs/platform/contextview/browser/contextView'; import {IKeybindingService} from 'vs/platform/keybinding/common/keybindingService'; -import {EditorOptions, UntitledEditorInput, IEditorGroup, IEditorStacksModel} from 'vs/workbench/common/editor'; +import {UntitledEditorInput, IEditorGroup, IEditorStacksModel} from 'vs/workbench/common/editor'; import {ITextFileService, AutoSaveMode, FileEditorInput, asFileResource} from 'vs/workbench/parts/files/common/files'; import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService'; import {EditorStacksModel, EditorGroup} from 'vs/workbench/common/editor/editorStacksModel'; @@ -344,7 +344,7 @@ export class Controller extends treedefaults.DefaultController { this.editorGroupService.pinEditor(position, element.editorInput); } this.editorGroupService.activateGroup(position); - this.editorService.openEditor(element.editorInput, EditorOptions.create({ preserveFocus: !pinEditor }), position) + this.editorService.openEditor(element.editorInput, { preserveFocus: !pinEditor }, position) .done(() => this.editorGroupService.activateGroup(position), errors.onUnexpectedError); } } diff --git a/src/vs/workbench/services/editor/browser/editorService.ts b/src/vs/workbench/services/editor/browser/editorService.ts index 8f04e636b80..2b54d04ecf0 100644 --- a/src/vs/workbench/services/editor/browser/editorService.ts +++ b/src/vs/workbench/services/editor/browser/editorService.ts @@ -99,6 +99,10 @@ export class WorkbenchEditorService implements IWorkbenchEditorService { // Workbench Input Support if (input instanceof EditorInput) { + if (!(arg2 instanceof EditorOptions)) { + arg2 = EditorOptions.create(arg2); + } + return this.doOpenEditor(input, arg2, arg3); } @@ -137,9 +141,14 @@ export class WorkbenchEditorService implements IWorkbenchEditorService { public openEditors(editors: any[]): TPromise { return TPromise.join(editors.map(editor => this.createInput(editor.input))).then(inputs => { const typedInputs: { input: EditorInput, position: Position, options?: EditorOptions }[] = inputs.map((input, index) => { + let options = editors[index].input instanceof EditorInput ? editors[index].options : TextEditorOptions.from(editors[index].input); + if (!(options instanceof EditorOptions)) { + options = EditorOptions.create(options); + } + return { input, - options: editors[index].input instanceof EditorInput ? editors[index].options : TextEditorOptions.from(editors[index].input), + options, position: editors[index].position }; }); @@ -149,15 +158,20 @@ export class WorkbenchEditorService implements IWorkbenchEditorService { } public replaceEditors(editors: { toReplace: IResourceInput, replaceWith: IResourceInput }[]): TPromise; - public replaceEditors(editors: { toReplace: EditorInput, replaceWith: EditorInput, options?: EditorOptions }[]): TPromise; + public replaceEditors(editors: { toReplace: EditorInput, replaceWith: EditorInput, options?: IEditorOptions }[]): TPromise; public replaceEditors(editors: any[]): TPromise { return TPromise.join(editors.map(editor => this.createInput(editor.toReplace))).then(toReplaceInputs => { return TPromise.join(editors.map(editor => this.createInput(editor.replaceWith))).then(replaceWithInputs => { const typedReplacements: { toReplace: EditorInput, replaceWith: EditorInput, options?: EditorOptions }[] = editors.map((editor, index) => { + let options = editor.toReplace instanceof EditorInput ? editor.options : TextEditorOptions.from(editor.replaceWith); + if (!(options instanceof EditorOptions)) { + options = EditorOptions.create(options); + } + return { toReplace: toReplaceInputs[index], replaceWith: replaceWithInputs[index], - options: editor.toReplace instanceof EditorInput ? editor.options : TextEditorOptions.from(editor.replaceWith) + options }; }); -- GitLab