diff --git a/src/vs/platform/editor/common/editor.ts b/src/vs/platform/editor/common/editor.ts index 897923795c77f5f1bbd193ddda3b0cbccf7f30bc..9b7cc2e9f5eb7c75fd0b7d30cf0e02aae33eb9dc 100644 --- a/src/vs/platform/editor/common/editor.ts +++ b/src/vs/platform/editor/common/editor.ts @@ -52,11 +52,6 @@ export interface IResourceInput { */ resource: URI; - /** - * The mime type of the text input if known. - */ - mime?: string; - /** * The encoding of the text input if known. */ diff --git a/src/vs/workbench/parts/files/browser/editors/textFileEditor.ts b/src/vs/workbench/parts/files/browser/editors/textFileEditor.ts index 8700eb3f7b210df2bdeb406dc2869690ccc5cfd2..e3f87ff280a52331f75041b48e51bcb0da8aa251 100644 --- a/src/vs/workbench/parts/files/browser/editors/textFileEditor.ts +++ b/src/vs/workbench/parts/files/browser/editors/textFileEditor.ts @@ -8,7 +8,7 @@ import {TPromise} from 'vs/base/common/winjs.base'; import nls = require('vs/nls'); import errors = require('vs/base/common/errors'); import {toErrorMessage} from 'vs/base/common/errorMessage'; -import {MIME_BINARY, MIME_TEXT} from 'vs/base/common/mime'; +import {MIME_BINARY} from 'vs/base/common/mime'; import types = require('vs/base/common/types'); import paths = require('vs/base/common/paths'); import {IEditorViewState} from 'vs/editor/common/editorCommon'; @@ -182,7 +182,6 @@ export class TextFileEditor extends BaseTextEditor { // Open return this.editorService.openEditor({ resource: input.getResource(), - mime: MIME_TEXT, options: { pinned: true // new file gets pinned by default } diff --git a/src/vs/workbench/parts/files/browser/fileActions.ts b/src/vs/workbench/parts/files/browser/fileActions.ts index 9858e2a8111a91b3f4ca30365d7b4ee142c3f8ff..d6bc9be0b6549b350be5a4028f68fba7bbfbf78e 100644 --- a/src/vs/workbench/parts/files/browser/fileActions.ts +++ b/src/vs/workbench/parts/files/browser/fileActions.ts @@ -10,7 +10,7 @@ import {TPromise} from 'vs/base/common/winjs.base'; import nls = require('vs/nls'); import {isWindows, isLinux, isMacintosh} from 'vs/base/common/platform'; import {sequence, ITask} from 'vs/base/common/async'; -import {MIME_TEXT, isUnspecific, isBinaryMime, guessMimeTypes} from 'vs/base/common/mime'; +import {isBinaryMime, guessMimeTypes} from 'vs/base/common/mime'; import paths = require('vs/base/common/paths'); import URI from 'vs/base/common/uri'; import errors = require('vs/base/common/errors'); @@ -1422,14 +1422,6 @@ export abstract class BaseSaveFileAction extends BaseActionWithErrorReporting { // Save As (or Save untitled with associated path) if (this.isSaveAs() || source.scheme === 'untitled') { - let mimeOfSource: string; - if (source.scheme === 'untitled') { - const selectedMime = this.untitledEditorService.get(source).getMime(); - if (!isUnspecific(selectedMime)) { - mimeOfSource = [selectedMime, MIME_TEXT].join(', '); - } - } - let encodingOfSource: string; if (source.scheme === 'untitled') { encodingOfSource = this.untitledEditorService.get(source).getEncoding(); @@ -1471,7 +1463,6 @@ export abstract class BaseSaveFileAction extends BaseActionWithErrorReporting { const replaceWith: IResourceInput = { resource: target, - mime: mimeOfSource, encoding: encodingOfSource, options: { pinned: true, @@ -1563,14 +1554,13 @@ export abstract class BaseSaveAllAction extends BaseActionWithErrorReporting { const stacks = this.editorGroupService.getStacksModel(); // Store some properties per untitled file to restore later after save is completed - const mapUntitledToProperties: { [resource: string]: { mime: string; encoding: string; indexInGroups: number[]; activeInGroups: boolean[] } } = Object.create(null); + const mapUntitledToProperties: { [resource: string]: { encoding: string; indexInGroups: number[]; activeInGroups: boolean[] } } = Object.create(null); this.textFileService.getDirty() .filter(r => r.scheme === 'untitled') // All untitled resources .map(r => this.untitledEditorService.get(r)) // Mapped to their inputs .filter(input => !!input) // If possible :) .forEach(input => { mapUntitledToProperties[input.getResource().toString()] = { - mime: input.getMime(), encoding: input.getEncoding(), indexInGroups: stacks.groups.map(g => g.indexOf(input)), activeInGroups: stacks.groups.map(g => g.isActive(input)) @@ -1593,18 +1583,12 @@ export abstract class BaseSaveAllAction extends BaseActionWithErrorReporting { return; } - let mimeOfSource: string; - if (!isUnspecific(untitledProps.mime)) { - mimeOfSource = [untitledProps.mime, MIME_TEXT].join(', '); - } - // For each position where the untitled file was opened untitledProps.indexInGroups.forEach((indexInGroup, index) => { if (indexInGroup >= 0) { untitledToReopen.push({ input: { resource: result.target, - mime: mimeOfSource, encoding: untitledProps.encoding, options: { pinned: true, diff --git a/src/vs/workbench/parts/files/browser/views/explorerView.ts b/src/vs/workbench/parts/files/browser/views/explorerView.ts index 87b3ceea99317f0e0d897da71d099841ec55fc75..fcc828278dd98edef1a15640b9a43668789f3f86 100644 --- a/src/vs/workbench/parts/files/browser/views/explorerView.ts +++ b/src/vs/workbench/parts/files/browser/views/explorerView.ts @@ -282,7 +282,7 @@ export class ExplorerView extends CollapsibleViewletView { private openFocusedElement(preserveFocus?: boolean): void { const stat: FileStat = this.explorerViewer.getFocus(); if (stat && !stat.isDirectory) { - this.editorService.openEditor({ resource: stat.resource, mime: stat.mime, options: { preserveFocus, revealIfVisible: true } }).done(null, errors.onUnexpectedError); + this.editorService.openEditor({ resource: stat.resource, options: { preserveFocus, revealIfVisible: true } }).done(null, errors.onUnexpectedError); } } diff --git a/src/vs/workbench/parts/files/browser/views/explorerViewer.ts b/src/vs/workbench/parts/files/browser/views/explorerViewer.ts index cace354b43c055e80964dae35015316e7bdc062f..a36e842e6e4f08b872d1ee1607b41d21452e32d2 100644 --- a/src/vs/workbench/parts/files/browser/views/explorerViewer.ts +++ b/src/vs/workbench/parts/files/browser/views/explorerViewer.ts @@ -611,7 +611,7 @@ export class FileController extends DefaultController { if (stat && !stat.isDirectory) { this.telemetryService.publicLog('workbenchActionExecuted', { id: 'workbench.files.openFile', from: 'explorer' }); - this.editorService.openEditor({ resource: stat.resource, mime: stat.mime, options: { preserveFocus, pinned } }, sideBySide).done(null, errors.onUnexpectedError); + this.editorService.openEditor({ resource: stat.resource, options: { preserveFocus, pinned } }, sideBySide).done(null, errors.onUnexpectedError); } } diff --git a/src/vs/workbench/parts/files/common/editors/fileEditorTracker.ts b/src/vs/workbench/parts/files/common/editors/fileEditorTracker.ts index 0feaf1177487bf3d187ce7277347a8abc460b30c..df9c192b1cb541f982067cf34e199a74ed0e51ed 100644 --- a/src/vs/workbench/parts/files/common/editors/fileEditorTracker.ts +++ b/src/vs/workbench/parts/files/common/editors/fileEditorTracker.ts @@ -6,7 +6,6 @@ import {IWorkbenchContribution} from 'vs/workbench/common/contributions'; import errors = require('vs/base/common/errors'); -import {MIME_UNKNOWN} from 'vs/base/common/mime'; import URI from 'vs/base/common/uri'; import paths = require('vs/base/common/paths'); import {DiffEditorInput} from 'vs/workbench/common/editor/diffEditorInput'; @@ -71,11 +70,11 @@ export class FileEditorTracker implements IWorkbenchContribution { const before = e.getBefore(); const after = e.getAfter(); - this.handleMovedFileInOpenedEditors(before ? before.resource : null, after ? after.resource : null, after ? after.mime : null); + this.handleMovedFileInOpenedEditors(before ? before.resource : null, after ? after.resource : null); } } - private handleMovedFileInOpenedEditors(oldResource: URI, newResource: URI, mimeHint?: string): void { + private handleMovedFileInOpenedEditors(oldResource: URI, newResource: URI): void { const stacks = this.editorGroupService.getStacksModel(); stacks.groups.forEach(group => { group.getEditors().forEach(input => { @@ -93,7 +92,7 @@ export class FileEditorTracker implements IWorkbenchContribution { } // Reopen - this.editorService.openEditor({ resource: reopenFileResource, mime: mimeHint || MIME_UNKNOWN, options: { preserveFocus: true, pinned: group.isPinned(input), index: group.indexOf(input), inactive: !group.isActive(input) } }, stacks.positionOfGroup(group)).done(null, errors.onUnexpectedError); + this.editorService.openEditor({ resource: reopenFileResource, options: { preserveFocus: true, pinned: group.isPinned(input), index: group.indexOf(input), inactive: !group.isActive(input) } }, stacks.positionOfGroup(group)).done(null, errors.onUnexpectedError); } } }); diff --git a/src/vs/workbench/parts/git/browser/gitActions.contribution.ts b/src/vs/workbench/parts/git/browser/gitActions.contribution.ts index cf0b5e3470f8b07f2d3545657bd03c78318f12e5..a38afaf371cb5d0e0ba2d1810f5bfe50daf66f38 100644 --- a/src/vs/workbench/parts/git/browser/gitActions.contribution.ts +++ b/src/vs/workbench/parts/git/browser/gitActions.contribution.ts @@ -189,7 +189,6 @@ class OpenInEditorAction extends baseeditor.EditorInputAction { return this.fileService.resolveFile(resource).then(stat => { return this.editorService.openEditor({ resource: stat.resource, - mime: stat.mime, options: { forceOpen: true } diff --git a/src/vs/workbench/parts/git/browser/gitActions.ts b/src/vs/workbench/parts/git/browser/gitActions.ts index 11f4b998eea023d795d6b2d428e9f657ee427883..de9a8af81e087f133a033155a4601491996b810d 100644 --- a/src/vs/workbench/parts/git/browser/gitActions.ts +++ b/src/vs/workbench/parts/git/browser/gitActions.ts @@ -173,7 +173,6 @@ export class OpenFileAction extends GitAction { return this.fileService.resolveFile(resource) .then(stat => this.editorService.openEditor({ resource: stat.resource, - mime: stat.mime, options: { forceOpen: true } })); } @@ -395,7 +394,6 @@ export abstract class BaseUndoAction extends GitAction { return this.fileService.resolveFile(this.contextService.toResource(path)).then((stat: IFileStat) => { return this.editorService.openEditor({ resource: stat.resource, - mime: stat.mime, options: { forceOpen: true } diff --git a/src/vs/workbench/services/editor/browser/editorService.ts b/src/vs/workbench/services/editor/browser/editorService.ts index 27c433ae478ddd4c96c5c5f40c76f68d5fd4165c..c5f826a7ed93632393392ed4594e1811382a9a2b 100644 --- a/src/vs/workbench/services/editor/browser/editorService.ts +++ b/src/vs/workbench/services/editor/browser/editorService.ts @@ -6,8 +6,8 @@ import {TPromise} from 'vs/base/common/winjs.base'; import URI from 'vs/base/common/uri'; -import network = require('vs/base/common/network'); import {guessMimeTypes} from 'vs/base/common/mime'; +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'); @@ -263,7 +263,7 @@ export class WorkbenchEditorService implements IWorkbenchEditorService { // Base Text Editor Support for file resources else if (this.fileInputDescriptor && resourceInput.resource instanceof URI && resourceInput.resource.scheme === network.Schemas.file) { - return this.createFileInput(resourceInput.resource, resourceInput.mime, resourceInput.encoding); + return this.createFileInput(resourceInput.resource, resourceInput.encoding); } // Treat an URI as ResourceEditorInput @@ -277,10 +277,10 @@ export class WorkbenchEditorService implements IWorkbenchEditorService { return TPromise.as(null); } - private createFileInput(resource: URI, mime?: string, encoding?: string): TPromise { + private createFileInput(resource: URI, encoding?: string): TPromise { return this.instantiationService.createInstance(this.fileInputDescriptor).then((typedFileInput) => { typedFileInput.setResource(resource); - typedFileInput.setMime(mime || guessMimeTypes(resource.fsPath).join(', ')); + typedFileInput.setMime(guessMimeTypes(resource.fsPath).join(', ')); typedFileInput.setPreferredEncoding(encoding); return typedFileInput; diff --git a/src/vs/workbench/test/browser/services.test.ts b/src/vs/workbench/test/browser/services.test.ts index c942d30c79f0c2d8008fc90262acb19ab442be1b..29ba658646eb0dde477246529f56c234049ed834 100644 --- a/src/vs/workbench/test/browser/services.test.ts +++ b/src/vs/workbench/test/browser/services.test.ts @@ -299,13 +299,12 @@ suite('Workbench UI Services', () => { }); // Open Untyped Input - service.openEditor({ resource: toResource('/index.html'), mime: 'text/html', options: { selection: { startLineNumber: 1, startColumn: 1 } } }).then((editor) => { + service.openEditor({ resource: toResource('/index.html'), options: { selection: { startLineNumber: 1, startColumn: 1 } } }).then((editor) => { assert.strictEqual(editor, activeEditor); assert(openedEditorInput instanceof FileEditorInput); let contentInput = openedEditorInput; assert.strictEqual(contentInput.getResource().fsPath, toResource('/index.html').fsPath); - assert.strictEqual(contentInput.getMime(), 'text/html'); assert(openedEditorOptions instanceof TextEditorOptions); let textEditorOptions = openedEditorOptions; @@ -327,7 +326,7 @@ suite('Workbench UI Services', () => { }); // Resolve Editor Model (Untyped Input) - service.resolveEditorModel({ resource: toResource('/index.html'), mime: 'text/html' }, true).then((model) => { + service.resolveEditorModel({ resource: toResource('/index.html') }, true).then((model) => { assert(model instanceof TextFileEditorModel); }); });