From 449882b9bb611a58bcbab9ec9b94756f98a39f01 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Wed, 4 Oct 2017 12:37:34 +0200 Subject: [PATCH] debt - remove hasResource() usage --- .../browser/parts/editor/editorActions.ts | 27 +++++++------------ src/vs/workbench/common/editor.ts | 4 --- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/src/vs/workbench/browser/parts/editor/editorActions.ts b/src/vs/workbench/browser/parts/editor/editorActions.ts index b0d39c75d15..aff43d76e7b 100644 --- a/src/vs/workbench/browser/parts/editor/editorActions.ts +++ b/src/vs/workbench/browser/parts/editor/editorActions.ts @@ -9,7 +9,7 @@ import nls = require('vs/nls'); import { Action } from 'vs/base/common/actions'; import { mixin } from 'vs/base/common/objects'; import { getCodeEditor } from 'vs/editor/common/services/codeEditorService'; -import { EditorInput, hasResource, TextEditorOptions, EditorOptions, IEditorIdentifier, IEditorContext, ActiveEditorMoveArguments, ActiveEditorMovePositioning, EditorCommands, ConfirmResult } from 'vs/workbench/common/editor'; +import { EditorInput, TextEditorOptions, EditorOptions, IEditorIdentifier, IEditorContext, ActiveEditorMoveArguments, ActiveEditorMovePositioning, EditorCommands, ConfirmResult } from 'vs/workbench/common/editor'; import { QuickOpenEntryGroup } from 'vs/base/parts/quickopen/browser/quickOpenModel'; import { EditorQuickOpenEntry, EditorQuickOpenEntryGroup, IEditorQuickOpenEntry, QuickOpenAction } from 'vs/workbench/browser/quickopen'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; @@ -255,16 +255,13 @@ export class FocusFirstGroupAction extends Action { // Since no editor is currently opened, try to open last history entry to the target side const history = this.historyService.getHistory(); - for (let input of history) { - - // For now only support to open files from history to the side + if (history.length > 0) { + const input = history[0]; if (input instanceof EditorInput) { - if (hasResource(input, { filter: ['file', 'untitled'] })) { - return this.editorService.openEditor(input, null, Position.ONE); - } - } else { - return this.editorService.openEditor(input as IResourceInput, Position.ONE); + return this.editorService.openEditor(input, null, Position.ONE); } + + return this.editorService.openEditor(input as IResourceInput, Position.ONE); } return TPromise.as(true); @@ -327,15 +324,11 @@ export abstract class BaseFocusSideGroupAction extends Action { else if (referenceEditor) { const history = this.historyService.getHistory(); for (let input of history) { - - // For now only support to open files from history to the side - if (input instanceof EditorInput) { - if (hasResource(input, { filter: ['file', 'untitled'] })) { - return this.editorService.openEditor(input, { pinned: true }, this.getTargetEditorSide()); - } - } else { - return this.editorService.openEditor({ resource: (input as IResourceInput).resource, options: { pinned: true } }, this.getTargetEditorSide()); + if (input instanceof EditorInput && input.supportsSplitEditor()) { + return this.editorService.openEditor(input, { pinned: true }, this.getTargetEditorSide()); } + + return this.editorService.openEditor({ resource: (input as IResourceInput).resource, options: { pinned: true } }, this.getTargetEditorSide()); } } diff --git a/src/vs/workbench/common/editor.ts b/src/vs/workbench/common/editor.ts index 5e8d989677a..c0165d7c69c 100644 --- a/src/vs/workbench/common/editor.ts +++ b/src/vs/workbench/common/editor.ts @@ -819,10 +819,6 @@ export interface IResourceOptions { filter?: 'file' | 'untitled' | ['file', 'untitled'] | ['untitled', 'file']; } -export function hasResource(editor: IEditorInput, options?: IResourceOptions): boolean { - return !!toResource(editor, options); -} - export function toResource(editor: IEditorInput, options?: IResourceOptions): URI { if (!editor) { return null; -- GitLab