From f68a4fccb6037ffaa102f216589869e7677a98ee Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Fri, 18 Nov 2016 14:58:27 +0100 Subject: [PATCH] remove need to resolve inmemory resources --- .../services/editor/browser/editorService.ts | 51 +------------------ .../common/textModelResolverService.ts | 12 ----- 2 files changed, 1 insertion(+), 62 deletions(-) diff --git a/src/vs/workbench/services/editor/browser/editorService.ts b/src/vs/workbench/services/editor/browser/editorService.ts index 06cf03b2ce7..0f4c79ef8aa 100644 --- a/src/vs/workbench/services/editor/browser/editorService.ts +++ b/src/vs/workbench/services/editor/browser/editorService.ts @@ -9,9 +9,6 @@ import URI from 'vs/base/common/uri'; import network = require('vs/base/common/network'); import { Registry } from 'vs/platform/platform'; import { basename, dirname } from 'vs/base/common/paths'; -import types = require('vs/base/common/types'); -import { IDiffEditor, ICodeEditor } from 'vs/editor/browser/editorBrowser'; -import { ICommonCodeEditor, IModel, EditorType, IEditor as ICommonEditor } from 'vs/editor/common/editorCommon'; import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor'; import { EditorInput, EditorOptions, IFileEditorInput, TextEditorOptions, IEditorRegistry, Extensions } from 'vs/workbench/common/editor'; import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput'; @@ -206,46 +203,9 @@ export class WorkbenchEditorService implements IWorkbenchEditorService { // Base Text Editor Support for inmemory resources const resourceInput = input; - if (resourceInput.resource instanceof URI && resourceInput.resource.scheme === network.Schemas.inMemory) { - - // For in-memory resources we only support to resolve the input from the current active editor - // because the workbench does not track editor models by in memory URL. This concept is only - // being used in the code editor. - const activeEditor = this.getActiveEditor(); - if (activeEditor) { - const control = activeEditor.getControl(); - if (types.isFunction(control.getEditorType)) { - - // Single Editor: If code editor model matches, return input from editor - if (control.getEditorType() === EditorType.ICodeEditor) { - const codeEditor = control; - const model = this.findModel(codeEditor, input); - if (model) { - return TPromise.as(activeEditor.input); - } - } - - // Diff Editor: If left or right code editor model matches, return associated input - else if (control.getEditorType() === EditorType.IDiffEditor) { - const diffInput = activeEditor.input; - const diffCodeEditor = control; - - const originalModel = this.findModel(diffCodeEditor.getOriginalEditor(), input); - if (originalModel) { - return TPromise.as(diffInput.originalInput); - } - - const modifiedModel = this.findModel(diffCodeEditor.getModifiedEditor(), input); - if (modifiedModel) { - return TPromise.as(diffInput.modifiedInput); - } - } - } - } - } // Untitled file support - else if (resourceInput.resource instanceof URI && (resourceInput.resource.scheme === UntitledEditorInput.SCHEMA)) { + if (resourceInput.resource instanceof URI && (resourceInput.resource.scheme === UntitledEditorInput.SCHEMA)) { return TPromise.as(this.untitledEditorService.createOrGet(resourceInput.resource)); } @@ -273,15 +233,6 @@ export class WorkbenchEditorService implements IWorkbenchEditorService { return typedFileInput; }); } - - private findModel(editor: ICommonCodeEditor, input: IResourceInput): IModel { - const model = editor.getModel(); - if (!model) { - return null; - } - - return model.uri.toString() === input.resource.toString() ? model : null; - } } export interface IDelegatingWorkbenchEditorServiceHandler { diff --git a/src/vs/workbench/services/textmodelResolver/common/textModelResolverService.ts b/src/vs/workbench/services/textmodelResolver/common/textModelResolverService.ts index aad206e758d..c2b28421265 100644 --- a/src/vs/workbench/services/textmodelResolver/common/textModelResolverService.ts +++ b/src/vs/workbench/services/textmodelResolver/common/textModelResolverService.ts @@ -19,7 +19,6 @@ import { ITextModelResolverService, ITextModelContentProvider } from 'vs/editor/ import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService'; import { UntitledEditorInput } from 'vs/workbench/common/editor/untitledEditorInput'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; -import { EditorInput } from 'vs/workbench/common/editor'; export class TextModelResolverService implements ITextModelResolverService { @@ -49,17 +48,6 @@ export class TextModelResolverService implements ITextModelResolverService { return this.untitledEditorService.createOrGet(resource).resolve(); } - // In Memory: only works on the active editor - if (resource.scheme === network.Schemas.inMemory) { - return this.editorService.createInput({ resource }).then(input => { - if (input instanceof EditorInput) { - return input.resolve(); - } - - return null; - }); - } - // Any other resource: use content provider registry return this.resolveTextModelContent(this.modelService, resource).then(() => this.instantiationService.createInstance(ResourceEditorModel, resource)); } -- GitLab