提交 fa7ce995 编写于 作者: B Benjamin Pasero

more fixes for #8578

上级 4d6ecd04
......@@ -17,7 +17,7 @@ import {dispose, IDisposable, Disposables} from 'vs/base/common/lifecycle';
import errors = require('vs/base/common/errors');
import {ContextViewService} from 'vs/platform/contextview/browser/contextViewService';
import timer = require('vs/base/common/timer');
import {Workbench} from 'vs/workbench/browser/workbench';
import {Workbench} from 'vs/workbench/electron-browser/workbench';
import {Storage, inMemoryLocalStorageInstance} from 'vs/workbench/common/storage';
import {ITelemetryService, NullTelemetryService} from 'vs/platform/telemetry/common/telemetry';
import {ITelemetryAppenderChannel, TelemetryAppenderClient} from 'vs/platform/telemetry/common/telemetryIpc';
......
......@@ -21,7 +21,6 @@ import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
import {IDisposable, dispose} from 'vs/base/common/lifecycle';
import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService';
import {IEditorGroupService} from 'vs/workbench/services/group/common/groupService';
import {ModelBuilder} from 'vs/editor/node/model/modelBuilder';
import {IModelService} from 'vs/editor/common/services/modelService';
/**
......@@ -49,7 +48,7 @@ export abstract class TextFileService implements ITextFileService {
@IEditorGroupService private editorGroupService: IEditorGroupService,
@IEventService private eventService: IEventService,
@IFileService protected fileService: IFileService,
@IModelService private modelService: IModelService
@IModelService protected modelService: IModelService
) {
this.listenerToUnbind = [];
this._onAutoSaveConfigurationChange = new Emitter<IAutoSaveConfiguration>();
......@@ -64,23 +63,7 @@ export abstract class TextFileService implements ITextFileService {
this.telemetryService.publicLog('autoSave', this.getAutoSaveConfiguration());
}
public resolveTextContent(resource: URI, options?: IResolveContentOptions): TPromise<IRawTextContent> {
return this.fileService.resolveStreamContent(resource, options).then((streamContent) => {
return ModelBuilder.fromStringStream(streamContent.value, this.modelService.getCreationOptions()).then((res) => {
let r: IRawTextContent = {
resource: streamContent.resource,
name: streamContent.name,
mtime: streamContent.mtime,
etag: streamContent.etag,
mime: streamContent.mime,
encoding: streamContent.encoding,
value: res.rawText,
valueLogicalHash: res.hash
};
return r;
});
});
}
public abstract resolveTextContent(resource: URI, options?: IResolveContentOptions): TPromise<IRawTextContent>;
public get onAutoSaveConfigurationChange(): Event<IAutoSaveConfiguration> {
return this._onAutoSaveConfigurationChange.event;
......
......@@ -16,9 +16,9 @@ import {ConfirmResult} from 'vs/workbench/common/editor';
import {IEventService} from 'vs/platform/event/common/event';
import {TextFileService as AbstractTextFileService} from 'vs/workbench/parts/files/browser/textFileServices';
import {CACHE, TextFileEditorModel} from 'vs/workbench/parts/files/common/editors/textFileEditorModel';
import {ITextFileOperationResult, AutoSaveMode} from 'vs/workbench/parts/files/common/files';
import {ITextFileOperationResult, AutoSaveMode, IRawTextContent} from 'vs/workbench/parts/files/common/files';
import {IUntitledEditorService} from 'vs/workbench/services/untitled/common/untitledEditorService';
import {IFileService} from 'vs/platform/files/common/files';
import {IFileService, IResolveContentOptions} from 'vs/platform/files/common/files';
import {BinaryEditorModel} from 'vs/workbench/common/editor/binaryEditorModel';
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
import {IWorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService';
......@@ -30,6 +30,7 @@ import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/edito
import {IWindowService} from 'vs/workbench/services/window/electron-browser/windowService';
import {IEditorGroupService} from 'vs/workbench/services/group/common/groupService';
import {IModelService} from 'vs/editor/common/services/modelService';
import {ModelBuilder} from 'vs/editor/node/model/modelBuilder';
export class TextFileService extends AbstractTextFileService {
......@@ -63,6 +64,24 @@ export class TextFileService extends AbstractTextFileService {
this.lifecycleService.onShutdown(this.onShutdown, this);
}
public resolveTextContent(resource: URI, options?: IResolveContentOptions): TPromise<IRawTextContent> {
return this.fileService.resolveStreamContent(resource, options).then((streamContent) => {
return ModelBuilder.fromStringStream(streamContent.value, this.modelService.getCreationOptions()).then((res) => {
let r: IRawTextContent = {
resource: streamContent.resource,
name: streamContent.name,
mtime: streamContent.mtime,
etag: streamContent.etag,
mime: streamContent.mime,
encoding: streamContent.encoding,
value: res.rawText,
valueLogicalHash: res.hash
};
return r;
});
});
}
public beforeShutdown(): boolean | TPromise<boolean> {
// Dirty files need treatment on shutdown
......
......@@ -54,7 +54,7 @@ import 'vs/workbench/parts/output/browser/output.contribution';
import 'vs/workbench/parts/terminal/electron-browser/terminal.contribution';
import 'vs/workbench/browser/workbench';
import 'vs/workbench/electron-browser/workbench';
import 'vs/workbench/parts/tasks/electron-browser/task.contribution';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册