diff --git a/src/vs/platform/files/common/files.ts b/src/vs/platform/files/common/files.ts index 3351b102af5..1b7f3d04446 100644 --- a/src/vs/platform/files/common/files.ts +++ b/src/vs/platform/files/common/files.ts @@ -101,11 +101,6 @@ export interface IFileService { */ exists(resource: URI): Promise; - /** - * @deprecated use readFile() instead. - */ - resolveContent(resource: URI, options?: IReadTextFileOptions): Promise; - /** * Read the contents of the provided resource unbuffered. */ @@ -1203,6 +1198,4 @@ export interface ILegacyFileService extends IDisposable { onAfterOperation: Event; registerProvider(scheme: string, provider: IFileSystemProvider): IDisposable; - - resolveContent(resource: URI, options?: IReadTextFileOptions): Promise; } \ No newline at end of file diff --git a/src/vs/workbench/browser/parts/editor/binaryEditor.ts b/src/vs/workbench/browser/parts/editor/binaryEditor.ts index 94d361655aa..07f065602c8 100644 --- a/src/vs/workbench/browser/parts/editor/binaryEditor.ts +++ b/src/vs/workbench/browser/parts/editor/binaryEditor.ts @@ -15,7 +15,7 @@ import { IThemeService } from 'vs/platform/theme/common/themeService'; import { ResourceViewerContext, ResourceViewer } from 'vs/workbench/browser/parts/editor/resourceViewer'; import { URI } from 'vs/base/common/uri'; import { Dimension, size, clearNode } from 'vs/base/browser/dom'; -import { IFileService } from 'vs/platform/files/common/files'; +import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; import { CancellationToken } from 'vs/base/common/cancellation'; import { dispose } from 'vs/base/common/lifecycle'; import { IStorageService } from 'vs/platform/storage/common/storage'; @@ -47,7 +47,7 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor { callbacks: IOpenCallbacks, telemetryService: ITelemetryService, themeService: IThemeService, - @IFileService private readonly _fileService: IFileService, + @ITextFileService private readonly textFileService: ITextFileService, @IStorageService storageService: IStorageService ) { super(id, telemetryService, themeService, storageService); @@ -89,7 +89,7 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor { // Render Input this.resourceViewerContext = ResourceViewer.show( { name: model.getName(), resource: model.getResource(), size: model.getSize(), etag: model.getETag(), mime: model.getMime() }, - this._fileService, + this.textFileService, this.binaryContainer, this.scrollbar, resource => this.handleOpenInternalCallback(input, options), diff --git a/src/vs/workbench/browser/parts/editor/editorStatus.ts b/src/vs/workbench/browser/parts/editor/editorStatus.ts index dbeebced34a..5cdbd92ce18 100644 --- a/src/vs/workbench/browser/parts/editor/editorStatus.ts +++ b/src/vs/workbench/browser/parts/editor/editorStatus.ts @@ -1144,7 +1144,8 @@ export class ChangeEncodingAction extends Action { @IEditorService private readonly editorService: IEditorService, @IQuickInputService private readonly quickInputService: IQuickInputService, @ITextResourceConfigurationService private readonly textResourceConfigurationService: ITextResourceConfigurationService, - @IFileService private readonly fileService: IFileService + @IFileService private readonly fileService: IFileService, + @ITextFileService private readonly textFileService: ITextFileService ) { super(actionId, actionLabel); } @@ -1195,7 +1196,7 @@ export class ChangeEncodingAction extends Action { return Promise.resolve(null); // encoding detection only possible for resources the file service can handle } - return this.fileService.resolveContent(resource, { autoGuessEncoding: true, acceptTextOnly: true }).then(content => content.encoding, err => null); + return this.textFileService.read(resource, { autoGuessEncoding: true, acceptTextOnly: true }).then(content => content.encoding, err => null); }) .then((guessedEncoding: string) => { const isReopenWithEncoding = (action === reopenWithEncodingPick); diff --git a/src/vs/workbench/browser/parts/editor/resourceViewer.ts b/src/vs/workbench/browser/parts/editor/resourceViewer.ts index 84a8cf568fd..5f88f3c041a 100644 --- a/src/vs/workbench/browser/parts/editor/resourceViewer.ts +++ b/src/vs/workbench/browser/parts/editor/resourceViewer.ts @@ -21,7 +21,7 @@ import { Action } from 'vs/base/common/actions'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { memoize } from 'vs/base/common/decorators'; import * as platform from 'vs/base/common/platform'; -import { IFileService } from 'vs/platform/files/common/files'; +import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; export interface IResourceDescriptor { readonly resource: URI; @@ -72,7 +72,7 @@ export class ResourceViewer { static show( descriptor: IResourceDescriptor, - fileService: IFileService, + textFileService: ITextFileService, container: HTMLElement, scrollbar: DomScrollableElement, openInternalClb: (uri: URI) => void, @@ -85,7 +85,7 @@ export class ResourceViewer { // Images if (ResourceViewer.isImageResource(descriptor)) { - return ImageView.create(container, descriptor, fileService, scrollbar, openExternalClb, metadataClb); + return ImageView.create(container, descriptor, textFileService, scrollbar, openExternalClb, metadataClb); } // Large Files @@ -114,13 +114,13 @@ class ImageView { static create( container: HTMLElement, descriptor: IResourceDescriptor, - fileService: IFileService, + textFileService: ITextFileService, scrollbar: DomScrollableElement, openExternalClb: (uri: URI) => void, metadataClb: (meta: string) => void ): ResourceViewerContext { if (ImageView.shouldShowImageInline(descriptor)) { - return InlineImageView.create(container, descriptor, fileService, scrollbar, metadataClb); + return InlineImageView.create(container, descriptor, textFileService, scrollbar, metadataClb); } return LargeImageView.create(container, descriptor, openExternalClb, metadataClb); @@ -357,7 +357,7 @@ class InlineImageView { static create( container: HTMLElement, descriptor: IResourceDescriptor, - fileService: IFileService, + textFileService: ITextFileService, scrollbar: DomScrollableElement, metadataClb: (meta: string) => void ) { @@ -559,7 +559,7 @@ class InlineImageView { } })); - InlineImageView.imageSrc(descriptor, fileService).then(dataUri => { + InlineImageView.imageSrc(descriptor, textFileService).then(dataUri => { const imgs = container.getElementsByTagName('img'); if (imgs.length) { imgs[0].src = dataUri; @@ -569,12 +569,12 @@ class InlineImageView { return context; } - private static imageSrc(descriptor: IResourceDescriptor, fileService: IFileService): Promise { + private static imageSrc(descriptor: IResourceDescriptor, textFileService: ITextFileService): Promise { if (descriptor.resource.scheme === Schemas.data) { return Promise.resolve(descriptor.resource.toString(true /* skip encoding */)); } - return fileService.resolveContent(descriptor.resource, { encoding: 'base64' }).then(data => { + return textFileService.read(descriptor.resource, { encoding: 'base64' }).then(data => { const mime = getMime(descriptor); return `data:${mime};base64,${data.value}`; diff --git a/src/vs/workbench/contrib/codeEditor/browser/languageConfigurationExtensionPoint.ts b/src/vs/workbench/contrib/codeEditor/browser/languageConfigurationExtensionPoint.ts index c3d785d048a..59060ed7fb4 100644 --- a/src/vs/workbench/contrib/codeEditor/browser/languageConfigurationExtensionPoint.ts +++ b/src/vs/workbench/contrib/codeEditor/browser/languageConfigurationExtensionPoint.ts @@ -97,7 +97,7 @@ export class LanguageConfigurationFileHandler { } private _handleConfigFile(languageIdentifier: LanguageIdentifier, configFileLocation: URI): void { - this._fileService.resolveContent(configFileLocation, { encoding: 'utf8' }).then((contents) => { + this._fileService.readFile(configFileLocation).then((contents) => { const errors: ParseError[] = []; const configuration = parse(contents.value.toString(), errors); if (errors.length) { diff --git a/src/vs/workbench/contrib/debug/electron-browser/debugConfigurationManager.ts b/src/vs/workbench/contrib/debug/electron-browser/debugConfigurationManager.ts index 1ee59ddda74..dad4cbfe6c1 100644 --- a/src/vs/workbench/contrib/debug/electron-browser/debugConfigurationManager.ts +++ b/src/vs/workbench/contrib/debug/electron-browser/debugConfigurationManager.ts @@ -559,7 +559,7 @@ class Launch extends AbstractLaunch implements ILaunch { const resource = this.uri; let created = false; - return this.fileService.resolveContent(resource).then(content => content.value, err => { + return this.fileService.readFile(resource).then(content => content.value, err => { // launch.json not found: create one by collecting launch configs from debugConfigProviders return this.configurationManager.guessDebugger(type).then(adapter => { if (adapter) { @@ -585,10 +585,11 @@ class Launch extends AbstractLaunch implements ILaunch { if (!content) { return { editor: null, created: false }; } - const index = content.indexOf(`"${this.configurationManager.selectedConfiguration.name}"`); + const contentValue = content.toString(); + const index = contentValue.indexOf(`"${this.configurationManager.selectedConfiguration.name}"`); let startLineNumber = 1; for (let i = 0; i < index; i++) { - if (content.charAt(i) === '\n') { + if (contentValue.charAt(i) === '\n') { startLineNumber++; } } diff --git a/src/vs/workbench/contrib/extensions/electron-browser/extensionTipsService.ts b/src/vs/workbench/contrib/extensions/electron-browser/extensionTipsService.ts index e58c5a2e2b9..27f7b93a97e 100644 --- a/src/vs/workbench/contrib/extensions/electron-browser/extensionTipsService.ts +++ b/src/vs/workbench/contrib/extensions/electron-browser/extensionTipsService.ts @@ -45,6 +45,7 @@ import { IExperimentService, ExperimentActionType, ExperimentState } from 'vs/wo import { CancellationToken } from 'vs/base/common/cancellation'; import { ExtensionType } from 'vs/platform/extensions/common/extensions'; import { extname } from 'vs/base/common/resources'; +import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; const milliSecondsInADay = 1000 * 60 * 60 * 24; const choiceNever = localize('neverShowAgain', "Don't Show Again"); @@ -108,6 +109,7 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe @IExtensionManagementService private readonly extensionManagementService: IExtensionManagementService, @IExtensionsWorkbenchService private readonly extensionWorkbenchService: IExtensionsWorkbenchService, @IExperimentService private readonly experimentService: IExperimentService, + @ITextFileService private readonly textFileService: ITextFileService ) { super(); @@ -325,8 +327,8 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe return Promise.resolve(null); } - return Promise.resolve(this.fileService.resolveContent(workspace.configuration) - .then(content => (json.parse(content.value)['extensions']), err => null)); + return Promise.resolve(this.fileService.readFile(workspace.configuration) + .then(content => (json.parse(content.value.toString())['extensions']), err => null)); } /** @@ -336,8 +338,8 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe const extensionsJsonUri = workspaceFolder.toResource(EXTENSIONS_CONFIG); return Promise.resolve(this.fileService.resolve(extensionsJsonUri) - .then(() => this.fileService.resolveContent(extensionsJsonUri)) - .then(content => json.parse(content.value), err => null)); + .then(() => this.fileService.readFile(extensionsJsonUri)) + .then(content => json.parse(content.value.toString()), err => null)); } /** @@ -956,7 +958,7 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe const storageKey = 'extensionsAssistant/dynamicWorkspaceRecommendations'; const workspaceUri = this.contextService.getWorkspace().folders[0].uri; - return Promise.all([getHashedRemotesFromUri(workspaceUri, this.fileService, false), getHashedRemotesFromUri(workspaceUri, this.fileService, true)]).then(([hashedRemotes1, hashedRemotes2]) => { + return Promise.all([getHashedRemotesFromUri(workspaceUri, this.fileService, this.textFileService, false), getHashedRemotesFromUri(workspaceUri, this.fileService, this.textFileService, true)]).then(([hashedRemotes1, hashedRemotes2]) => { const hashedRemotes = (hashedRemotes1 || []).concat(hashedRemotes2 || []); if (!hashedRemotes.length) { return undefined; diff --git a/src/vs/workbench/contrib/extensions/electron-browser/extensionsActions.ts b/src/vs/workbench/contrib/extensions/electron-browser/extensionsActions.ts index d5a00880d2b..2ba119482c5 100644 --- a/src/vs/workbench/contrib/extensions/electron-browser/extensionsActions.ts +++ b/src/vs/workbench/contrib/extensions/electron-browser/extensionsActions.ts @@ -22,7 +22,7 @@ import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiati import { ShowViewletAction } from 'vs/workbench/browser/viewlet'; import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet'; import { Query } from 'vs/workbench/contrib/extensions/common/extensionQuery'; -import { IFileService, IContent } from 'vs/platform/files/common/files'; +import { IFileService, IFileContent } from 'vs/platform/files/common/files'; import { IWorkspaceContextService, WorkbenchState, IWorkspaceFolder } from 'vs/platform/workspace/common/workspace'; import { IWindowService, IWindowsService } from 'vs/platform/windows/common/windows'; import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; @@ -2031,7 +2031,7 @@ export abstract class AbstractConfigureRecommendedExtensionsAction extends Actio protected openWorkspaceConfigurationFile(workspaceConfigurationFile: URI): Promise { return this.getOrUpdateWorkspaceConfigurationFile(workspaceConfigurationFile) - .then(content => this.getSelectionPosition(content.value, content.resource, ['extensions', 'recommendations'])) + .then(content => this.getSelectionPosition(content.value.toString(), content.resource, ['extensions', 'recommendations'])) .then(selection => this.editorService.openEditor({ resource: workspaceConfigurationFile, options: { @@ -2045,7 +2045,7 @@ export abstract class AbstractConfigureRecommendedExtensionsAction extends Actio return this.getOrUpdateWorkspaceConfigurationFile(workspaceConfigurationFile) .then(content => { const extensionIdLowerCase = extensionId.toLowerCase(); - const workspaceExtensionsConfigContent: IExtensionsConfigContent = (json.parse(content.value) || {})['extensions'] || {}; + const workspaceExtensionsConfigContent: IExtensionsConfigContent = (json.parse(content.value.toString()) || {})['extensions'] || {}; let insertInto = shouldRecommend ? workspaceExtensionsConfigContent.recommendations || [] : workspaceExtensionsConfigContent.unwantedRecommendations || []; let removeFrom = shouldRecommend ? workspaceExtensionsConfigContent.unwantedRecommendations || [] : workspaceExtensionsConfigContent.recommendations || []; @@ -2105,26 +2105,26 @@ export abstract class AbstractConfigureRecommendedExtensionsAction extends Actio } protected getWorkspaceExtensionsConfigContent(extensionsFileResource: URI): Promise { - return Promise.resolve(this.fileService.resolveContent(extensionsFileResource)) + return Promise.resolve(this.fileService.readFile(extensionsFileResource)) .then(content => { - return (json.parse(content.value) || {})['extensions'] || {}; + return (json.parse(content.value.toString()) || {})['extensions'] || {}; }, err => ({ recommendations: [], unwantedRecommendations: [] })); } protected getWorkspaceFolderExtensionsConfigContent(extensionsFileResource: URI): Promise { - return Promise.resolve(this.fileService.resolveContent(extensionsFileResource)) + return Promise.resolve(this.fileService.readFile(extensionsFileResource)) .then(content => { - return (json.parse(content.value)); + return (json.parse(content.value.toString())); }, err => ({ recommendations: [], unwantedRecommendations: [] })); } - private getOrUpdateWorkspaceConfigurationFile(workspaceConfigurationFile: URI): Promise { - return Promise.resolve(this.fileService.resolveContent(workspaceConfigurationFile)) + private getOrUpdateWorkspaceConfigurationFile(workspaceConfigurationFile: URI): Promise { + return Promise.resolve(this.fileService.readFile(workspaceConfigurationFile)) .then(content => { - const workspaceRecommendations = json.parse(content.value)['extensions']; + const workspaceRecommendations = json.parse(content.value.toString())['extensions']; if (!workspaceRecommendations || !workspaceRecommendations.recommendations) { return this.jsonEditingService.write(workspaceConfigurationFile, { key: 'extensions', value: { recommendations: [] } }, true) - .then(() => this.fileService.resolveContent(workspaceConfigurationFile)); + .then(() => this.fileService.readFile(workspaceConfigurationFile)); } return content; }); @@ -2153,8 +2153,8 @@ export abstract class AbstractConfigureRecommendedExtensionsAction extends Actio } private getOrCreateExtensionsFile(extensionsFileResource: URI): Promise<{ created: boolean, extensionsFileResource: URI, content: string }> { - return Promise.resolve(this.fileService.resolveContent(extensionsFileResource)).then(content => { - return { created: false, extensionsFileResource, content: content.value }; + return Promise.resolve(this.fileService.readFile(extensionsFileResource)).then(content => { + return { created: false, extensionsFileResource, content: content.value.toString() }; }, err => { return this.textFileService.write(extensionsFileResource, ExtensionsConfigurationInitialContent).then(() => { return { created: true, extensionsFileResource, content: ExtensionsConfigurationInitialContent }; diff --git a/src/vs/workbench/contrib/extensions/node/extensionsWorkbenchService.ts b/src/vs/workbench/contrib/extensions/node/extensionsWorkbenchService.ts index 417ca8bfd76..6fe65c58580 100644 --- a/src/vs/workbench/contrib/extensions/node/extensionsWorkbenchService.ts +++ b/src/vs/workbench/contrib/extensions/node/extensionsWorkbenchService.ts @@ -236,7 +236,7 @@ class Extension implements IExtension { } if (this.local && this.local.readmeUrl) { - return this.fileService.resolveContent(this.local.readmeUrl, { encoding: 'utf8' }).then(content => content.value); + return this.fileService.readFile(this.local.readmeUrl).then(content => content.value.toString()); } if (this.type === ExtensionType.System) { @@ -277,7 +277,7 @@ ${this.description} return Promise.reject(new Error('not available')); } - return this.fileService.resolveContent(changelogUrl, { encoding: 'utf8' }).then(content => content.value); + return this.fileService.readFile(changelogUrl).then(content => content.value.toString()); } get dependencies(): string[] { diff --git a/src/vs/workbench/contrib/files/browser/editors/binaryFileEditor.ts b/src/vs/workbench/contrib/files/browser/editors/binaryFileEditor.ts index 854da7251dc..f448bc664ff 100644 --- a/src/vs/workbench/contrib/files/browser/editors/binaryFileEditor.ts +++ b/src/vs/workbench/contrib/files/browser/editors/binaryFileEditor.ts @@ -12,9 +12,9 @@ import { EditorInput, EditorOptions } from 'vs/workbench/common/editor'; import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput'; import { URI } from 'vs/base/common/uri'; import { BINARY_FILE_EDITOR_ID } from 'vs/workbench/contrib/files/common/files'; -import { IFileService } from 'vs/platform/files/common/files'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IStorageService } from 'vs/platform/storage/common/storage'; +import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; /** * An implementation of editor for binary files like images. @@ -26,10 +26,10 @@ export class BinaryFileEditor extends BaseBinaryResourceEditor { constructor( @ITelemetryService telemetryService: ITelemetryService, @IThemeService themeService: IThemeService, - @IFileService fileService: IFileService, @IWindowsService private readonly windowsService: IWindowsService, @IEditorService private readonly editorService: IEditorService, - @IStorageService storageService: IStorageService + @IStorageService storageService: IStorageService, + @ITextFileService textFileService: ITextFileService ) { super( BinaryFileEditor.ID, @@ -39,7 +39,7 @@ export class BinaryFileEditor extends BaseBinaryResourceEditor { }, telemetryService, themeService, - fileService, + textFileService, storageService ); } diff --git a/src/vs/workbench/contrib/snippets/browser/snippetsFile.ts b/src/vs/workbench/contrib/snippets/browser/snippetsFile.ts index dc3d82ca9fd..9b298b9d560 100644 --- a/src/vs/workbench/contrib/snippets/browser/snippetsFile.ts +++ b/src/vs/workbench/contrib/snippets/browser/snippetsFile.ts @@ -198,7 +198,7 @@ export class SnippetFile { load(): Promise { if (!this._loadPromise) { - this._loadPromise = Promise.resolve(this._fileService.resolveContent(this.location, { encoding: 'utf8' })).then(content => { + this._loadPromise = Promise.resolve(this._fileService.readFile(this.location)).then(content => { const data = jsonParse(content.value.toString()); if (typeof data === 'object') { forEach(data, entry => { diff --git a/src/vs/workbench/contrib/stats/node/workspaceStats.ts b/src/vs/workbench/contrib/stats/node/workspaceStats.ts index da188140e8f..128fb0a8f89 100644 --- a/src/vs/workbench/contrib/stats/node/workspaceStats.ts +++ b/src/vs/workbench/contrib/stats/node/workspaceStats.ts @@ -20,6 +20,7 @@ import { hasWorkspaceFileExtension } from 'vs/platform/workspaces/common/workspa import { IQuickInputService, IQuickPickItem } from 'vs/platform/quickinput/common/quickInput'; import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; import { joinPath } from 'vs/base/common/resources'; +import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; const SshProtocolMatcher = /^([^@:]+@)?([^:]+):/; const SshUrlMatcher = /^([^@:]+@)?([^:]+):(.+)$/; @@ -193,14 +194,14 @@ export function getHashedRemotesFromConfig(text: string, stripEndingDotGit: bool }); } -export function getHashedRemotesFromUri(workspaceUri: URI, fileService: IFileService, stripEndingDotGit: boolean = false): Promise { +export function getHashedRemotesFromUri(workspaceUri: URI, fileService: IFileService, textFileService: ITextFileService, stripEndingDotGit: boolean = false): Promise { const path = workspaceUri.path; const uri = workspaceUri.with({ path: `${path !== '/' ? path : ''}/.git/config` }); return fileService.exists(uri).then(exists => { if (!exists) { return []; } - return fileService.resolveContent(uri, { acceptTextOnly: true }).then( + return textFileService.read(uri, { acceptTextOnly: true }).then( content => getHashedRemotesFromConfig(content.value, stripEndingDotGit), err => [] // ignore missing or binary file ); @@ -221,7 +222,8 @@ export class WorkspaceStats implements IWorkbenchContribution { @IWindowService private readonly windowService: IWindowService, @INotificationService private readonly notificationService: INotificationService, @IQuickInputService private readonly quickInputService: IQuickInputService, - @IStorageService private readonly storageService: IStorageService + @IStorageService private readonly storageService: IStorageService, + @ITextFileService private readonly textFileService: ITextFileService ) { this.report(); } @@ -434,7 +436,7 @@ export class WorkspaceStats implements IWorkbenchContribution { tags['workspace.android.cpp'] = true; } - function getFilePromises(filename: string, fileService: IFileService, contentHandler: (content: IContent) => void): Promise[] { + function getFilePromises(filename: string, fileService: IFileService, textFileService: ITextFileService, contentHandler: (content: IContent) => void): Promise[] { return !nameSet.has(filename) ? [] : (folders as URI[]).map(workspaceUri => { const uri = workspaceUri.with({ path: `${workspaceUri.path !== '/' ? workspaceUri.path : ''}/${filename}` }); return fileService.exists(uri).then(exists => { @@ -442,7 +444,7 @@ export class WorkspaceStats implements IWorkbenchContribution { return undefined; } - return fileService.resolveContent(uri, { acceptTextOnly: true }).then(contentHandler); + return textFileService.read(uri, { acceptTextOnly: true }).then(contentHandler); }, err => { // Ignore missing file }); @@ -468,7 +470,7 @@ export class WorkspaceStats implements IWorkbenchContribution { } } - const requirementsTxtPromises = getFilePromises('requirements.txt', this.fileService, content => { + const requirementsTxtPromises = getFilePromises('requirements.txt', this.fileService, this.textFileService, content => { const dependencies: string[] = content.value.split(/\r\n|\r|\n/); for (let dependency of dependencies) { // Dependencies in requirements.txt can have 3 formats: `foo==3.1, foo>=3.1, foo` @@ -479,7 +481,7 @@ export class WorkspaceStats implements IWorkbenchContribution { } }); - const pipfilePromises = getFilePromises('pipfile', this.fileService, content => { + const pipfilePromises = getFilePromises('pipfile', this.fileService, this.textFileService, content => { let dependencies: string[] = content.value.split(/\r\n|\r|\n/); // We're only interested in the '[packages]' section of the Pipfile @@ -499,7 +501,7 @@ export class WorkspaceStats implements IWorkbenchContribution { }); - const packageJsonPromises = getFilePromises('package.json', this.fileService, content => { + const packageJsonPromises = getFilePromises('package.json', this.fileService, this.textFileService, content => { try { const packageJsonContents = JSON.parse(content.value); if (packageJsonContents['dependencies']) { @@ -624,7 +626,7 @@ export class WorkspaceStats implements IWorkbenchContribution { if (!exists) { return []; } - return this.fileService.resolveContent(uri, { acceptTextOnly: true }).then( + return this.textFileService.read(uri, { acceptTextOnly: true }).then( content => getDomainsOfRemotes(content.value, SecondLevelDomainWhitelist), err => [] // ignore missing or binary file ); @@ -644,7 +646,7 @@ export class WorkspaceStats implements IWorkbenchContribution { private reportRemotes(workspaceUris: URI[]): void { Promise.all(workspaceUris.map(workspaceUri => { - return getHashedRemotesFromUri(workspaceUri, this.fileService, true); + return getHashedRemotesFromUri(workspaceUri, this.fileService, this.textFileService, true); })).then(hashedRemotes => { /* __GDPR__ "workspace.hashedRemotes" : { @@ -693,7 +695,7 @@ export class WorkspaceStats implements IWorkbenchContribution { if (!exists) { return false; } - return this.fileService.resolveContent(uri, { acceptTextOnly: true }).then( + return this.textFileService.read(uri, { acceptTextOnly: true }).then( content => !!content.value.match(/azure/i), err => false ); diff --git a/src/vs/workbench/contrib/themes/test/electron-browser/themes.test.contribution.ts b/src/vs/workbench/contrib/themes/test/electron-browser/themes.test.contribution.ts index 1142d57524b..fdabd1a9971 100644 --- a/src/vs/workbench/contrib/themes/test/electron-browser/themes.test.contribution.ts +++ b/src/vs/workbench/contrib/themes/test/electron-browser/themes.test.contribution.ts @@ -234,8 +234,8 @@ CommandsRegistry.registerCommand('_workbench.captureSyntaxTokens', function (acc let fileName = basename(resource); let snapper = accessor.get(IInstantiationService).createInstance(Snapper); - return fileService.resolveContent(resource).then(content => { - return snapper.captureSyntaxTokens(fileName, content.value); + return fileService.readFile(resource).then(content => { + return snapper.captureSyntaxTokens(fileName, content.value.toString()); }); }; diff --git a/src/vs/workbench/contrib/webview/electron-browser/webviewElement.ts b/src/vs/workbench/contrib/webview/electron-browser/webviewElement.ts index e8ac299bd3a..1477b88a213 100644 --- a/src/vs/workbench/contrib/webview/electron-browser/webviewElement.ts +++ b/src/vs/workbench/contrib/webview/electron-browser/webviewElement.ts @@ -16,7 +16,7 @@ import * as modes from 'vs/editor/common/modes'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions'; -import { IFileService } from 'vs/platform/files/common/files'; +import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { REMOTE_HOST_SCHEME } from 'vs/platform/remote/common/remoteHosts'; import { ITunnelService, RemoteTunnel } from 'vs/platform/remote/common/tunnel'; @@ -118,7 +118,7 @@ class WebviewProtocolProvider extends Disposable { private readonly _extensionLocation: URI | undefined, private readonly _getLocalResourceRoots: () => ReadonlyArray, private readonly _environmentService: IEnvironmentService, - private readonly _fileService: IFileService, + private readonly _textFileService: ITextFileService, ) { super(); @@ -137,11 +137,11 @@ class WebviewProtocolProvider extends Disposable { const appRootUri = URI.file(this._environmentService.appRoot); - registerFileProtocol(contents, WebviewProtocol.CoreResource, this._fileService, undefined, () => [ + registerFileProtocol(contents, WebviewProtocol.CoreResource, this._textFileService, undefined, () => [ appRootUri ]); - registerFileProtocol(contents, WebviewProtocol.VsCodeResource, this._fileService, this._extensionLocation, () => + registerFileProtocol(contents, WebviewProtocol.VsCodeResource, this._textFileService, this._extensionLocation, () => this._getLocalResourceRoots() ); } @@ -374,7 +374,7 @@ export class WebviewElement extends Disposable implements Webview { @IInstantiationService instantiationService: IInstantiationService, @IThemeService themeService: IThemeService, @IEnvironmentService environmentService: IEnvironmentService, - @IFileService fileService: IFileService, + @ITextFileService textFileService: ITextFileService, @ITunnelService tunnelService: ITunnelService, @ITelemetryService telemetryService: ITelemetryService, @IConfigurationService private readonly _configurationService: IConfigurationService, @@ -412,7 +412,7 @@ export class WebviewElement extends Disposable implements Webview { this._options.extension ? this._options.extension.location : undefined, () => (this._contentOptions.localResourceRoots || []), environmentService, - fileService)); + textFileService)); this._register(new WebviewPortMappingProvider( session, diff --git a/src/vs/workbench/contrib/webview/electron-browser/webviewProtocols.ts b/src/vs/workbench/contrib/webview/electron-browser/webviewProtocols.ts index 8681fa6ce23..d77ed52daf6 100644 --- a/src/vs/workbench/contrib/webview/electron-browser/webviewProtocols.ts +++ b/src/vs/workbench/contrib/webview/electron-browser/webviewProtocols.ts @@ -6,16 +6,16 @@ import { getMediaMime, MIME_UNKNOWN } from 'vs/base/common/mime'; import { extname, sep } from 'vs/base/common/path'; import { startsWith } from 'vs/base/common/strings'; import { URI } from 'vs/base/common/uri'; -import { IFileService } from 'vs/platform/files/common/files'; import { REMOTE_HOST_SCHEME } from 'vs/platform/remote/common/remoteHosts'; +import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; export const enum WebviewProtocol { CoreResource = 'vscode-core-resource', VsCodeResource = 'vscode-resource', } -function resolveContent(fileService: IFileService, resource: URI, mime: string, callback: any): void { - fileService.resolveContent(resource, { encoding: 'binary' }).then(contents => { +function resolveContent(textFileService: ITextFileService, resource: URI, mime: string, callback: any): void { + textFileService.read(resource, { encoding: 'binary' }).then(contents => { callback({ data: Buffer.from(contents.value, contents.encoding), mimeType: mime @@ -29,7 +29,7 @@ function resolveContent(fileService: IFileService, resource: URI, mime: string, export function registerFileProtocol( contents: Electron.WebContents, protocol: WebviewProtocol, - fileService: IFileService, + textFileService: ITextFileService, extensionLocation: URI | undefined, getRoots: () => ReadonlyArray ) { @@ -44,7 +44,7 @@ export function registerFileProtocol( requestResourcePath: requestUri.path }) }); - resolveContent(fileService, redirectedUri, getMimeType(requestUri), callback); + resolveContent(textFileService, redirectedUri, getMimeType(requestUri), callback); return; } @@ -52,7 +52,7 @@ export function registerFileProtocol( const normalizedPath = URI.file(requestPath); for (const root of getRoots()) { if (startsWith(normalizedPath.fsPath, root.fsPath + sep)) { - resolveContent(fileService, normalizedPath, getMimeType(normalizedPath), callback); + resolveContent(textFileService, normalizedPath, getMimeType(normalizedPath), callback); return; } } diff --git a/src/vs/workbench/services/configuration/browser/configuration.ts b/src/vs/workbench/services/configuration/browser/configuration.ts index 9ce17f99298..fa8935c80cb 100644 --- a/src/vs/workbench/services/configuration/browser/configuration.ts +++ b/src/vs/workbench/services/configuration/browser/configuration.ts @@ -133,7 +133,7 @@ export class UserConfiguration extends Disposable { async reload(): Promise { try { - const content = await this.configurationFileService.resolveContent(this.configurationResource); + const content = await this.configurationFileService.readFile(this.configurationResource); this.parser.parseContent(content); return this.parser.configurationModel; } catch (e) { @@ -379,7 +379,7 @@ class FileServiceBasedWorkspaceConfiguration extends Disposable implements IWork } let contents = ''; try { - contents = await this.configurationFileService.resolveContent(this._workspaceIdentifier.configPath); + contents = await this.configurationFileService.readFile(this._workspaceIdentifier.configPath); } catch (error) { const exists = await this.configurationFileService.exists(this._workspaceIdentifier.configPath); if (exists) { @@ -547,7 +547,7 @@ class FileServiceBasedFolderConfiguration extends Disposable implements IFolderC async loadConfiguration(): Promise { const configurationContents = await Promise.all(this.configurationResources.map(async resource => { try { - return await this.configurationFileService.resolveContent(resource); + return await this.configurationFileService.readFile(resource); } catch (error) { const exists = await this.configurationFileService.exists(resource); if (exists) { diff --git a/src/vs/workbench/services/configuration/common/configuration.ts b/src/vs/workbench/services/configuration/common/configuration.ts index c8ec23ec441..02192c4c871 100644 --- a/src/vs/workbench/services/configuration/common/configuration.ts +++ b/src/vs/workbench/services/configuration/common/configuration.ts @@ -49,7 +49,7 @@ export interface IConfigurationFileService { whenProviderRegistered(scheme: string): Promise; watch(resource: URI): IDisposable; exists(resource: URI): Promise; - resolveContent(resource: URI): Promise; + readFile(resource: URI): Promise; } export class ConfigurationFileService implements IConfigurationFileService { @@ -82,8 +82,8 @@ export class ConfigurationFileService implements IConfigurationFileService { return this.fileService.exists(resource); } - resolveContent(resource: URI): Promise { - return this.fileService.resolveContent(resource, { encoding: 'utf8' }).then(content => content.value); + readFile(resource: URI): Promise { + return this.fileService.readFile(resource).then(content => content.value.toString()); } } diff --git a/src/vs/workbench/services/configuration/node/configurationFileService.ts b/src/vs/workbench/services/configuration/node/configurationFileService.ts index 77bcc9cdbbe..18690c44040 100644 --- a/src/vs/workbench/services/configuration/node/configurationFileService.ts +++ b/src/vs/workbench/services/configuration/node/configurationFileService.ts @@ -51,9 +51,9 @@ export class ConfigurationFileService extends Disposable implements IConfigurati return this._fileServiceBasedConfigurationFileService ? this._fileServiceBasedConfigurationFileService.exists(resource) : pfs.exists(resource.fsPath); } - async resolveContent(resource: URI): Promise { + async readFile(resource: URI): Promise { if (this._fileServiceBasedConfigurationFileService) { - return this._fileServiceBasedConfigurationFileService.resolveContent(resource); + return this._fileServiceBasedConfigurationFileService.readFile(resource); } else { const contents = await pfs.readFile(resource.fsPath); return contents.toString(); diff --git a/src/vs/workbench/services/files2/common/fileService2.ts b/src/vs/workbench/services/files2/common/fileService2.ts index 5f134821700..a5dfd6f7d73 100644 --- a/src/vs/workbench/services/files2/common/fileService2.ts +++ b/src/vs/workbench/services/files2/common/fileService2.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { Disposable, IDisposable, toDisposable, combinedDisposable, dispose } from 'vs/base/common/lifecycle'; -import { IFileService, IResolveFileOptions, FileChangesEvent, FileOperationEvent, IFileSystemProviderRegistrationEvent, IFileSystemProvider, IFileStat, IResolveFileResult, IReadTextFileOptions, IContent, ICreateFileOptions, IFileSystemProviderActivationEvent, FileOperationError, FileOperationResult, FileOperation, FileSystemProviderCapabilities, FileType, toFileSystemProviderErrorCode, FileSystemProviderErrorCode, IStat, IFileStatWithMetadata, IResolveMetadataFileOptions, etag, hasReadWriteCapability, hasFileFolderCopyCapability, hasOpenReadWriteCloseCapability, toFileOperationResult, IFileSystemProviderWithOpenReadWriteCloseCapability, IFileSystemProviderWithFileReadWriteCapability, IResolveFileResultWithMetadata, IWatchOptions, ILegacyFileService, IWriteFileOptions, IReadFileOptions, IFileStreamContent, IFileContent } from 'vs/platform/files/common/files'; +import { IFileService, IResolveFileOptions, FileChangesEvent, FileOperationEvent, IFileSystemProviderRegistrationEvent, IFileSystemProvider, IFileStat, IResolveFileResult, ICreateFileOptions, IFileSystemProviderActivationEvent, FileOperationError, FileOperationResult, FileOperation, FileSystemProviderCapabilities, FileType, toFileSystemProviderErrorCode, FileSystemProviderErrorCode, IStat, IFileStatWithMetadata, IResolveMetadataFileOptions, etag, hasReadWriteCapability, hasFileFolderCopyCapability, hasOpenReadWriteCloseCapability, toFileOperationResult, IFileSystemProviderWithOpenReadWriteCloseCapability, IFileSystemProviderWithFileReadWriteCapability, IResolveFileResultWithMetadata, IWatchOptions, ILegacyFileService, IWriteFileOptions, IReadFileOptions, IFileStreamContent, IFileContent } from 'vs/platform/files/common/files'; import { URI } from 'vs/base/common/uri'; import { Event, Emitter } from 'vs/base/common/event'; import { ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation'; @@ -528,10 +528,6 @@ export class FileService2 extends Disposable implements IFileService { return stat; } - resolveContent(resource: URI, options?: IReadTextFileOptions): Promise { - return this.joinOnLegacy.then(legacy => legacy.resolveContent(resource, options)); - } - //#endregion //#region Move/Copy/Delete/Create Folder diff --git a/src/vs/workbench/services/output/common/outputChannelModel.ts b/src/vs/workbench/services/output/common/outputChannelModel.ts index 9f8f84fe8bb..007ead80d15 100644 --- a/src/vs/workbench/services/output/common/outputChannelModel.ts +++ b/src/vs/workbench/services/output/common/outputChannelModel.ts @@ -210,11 +210,11 @@ class FileOutputChannelModel extends AbstractFileOutputChannelModel implements I } loadModel(): Promise { - this.loadModelPromise = this.fileService.resolveContent(this.file, { position: this.startOffset, encoding: 'utf8' }) + this.loadModelPromise = this.fileService.readFile(this.file, { position: this.startOffset }) .then(content => { - this.endOffset = this.startOffset + this.getByteLength(content.value); + this.endOffset = this.startOffset + content.value.byteLength; this.etag = content.etag; - return this.createModel(content.value); + return this.createModel(content.value.toString()); }); return this.loadModelPromise; } @@ -233,12 +233,12 @@ class FileOutputChannelModel extends AbstractFileOutputChannelModel implements I protected updateModel(): void { if (this.model) { - this.fileService.resolveContent(this.file, { position: this.endOffset, encoding: 'utf8' }) + this.fileService.readFile(this.file, { position: this.endOffset }) .then(content => { this.etag = content.etag; if (content.value) { - this.endOffset = this.endOffset + this.getByteLength(content.value); - this.appendToModel(content.value); + this.endOffset = this.endOffset + content.value.byteLength; + this.appendToModel(content.value.toString()); } this.updateInProgress = false; }, () => this.updateInProgress = false); diff --git a/src/vs/workbench/services/output/node/outputChannelModelService.ts b/src/vs/workbench/services/output/node/outputChannelModelService.ts index 004e4860981..7f540132bce 100644 --- a/src/vs/workbench/services/output/node/outputChannelModelService.ts +++ b/src/vs/workbench/services/output/node/outputChannelModelService.ts @@ -117,8 +117,8 @@ class OutputChannelBackedByFile extends AbstractFileOutputChannelModel implement } private loadFile(): Promise { - return this.fileService.resolveContent(this.file, { position: this.startOffset, encoding: 'utf8' }) - .then(content => this.appendedMessage ? content.value + this.appendedMessage : content.value); + return this.fileService.readFile(this.file, { position: this.startOffset }) + .then(content => this.appendedMessage ? content.value + this.appendedMessage : content.value.toString()); } protected updateModel(): void { diff --git a/src/vs/workbench/services/preferences/browser/preferencesService.ts b/src/vs/workbench/services/preferences/browser/preferencesService.ts index 6f002c8a35f..f12750b17ef 100644 --- a/src/vs/workbench/services/preferences/browser/preferencesService.ts +++ b/src/vs/workbench/services/preferences/browser/preferencesService.ts @@ -21,7 +21,7 @@ import * as nls from 'vs/nls'; import { ConfigurationTarget, IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IEditorOptions } from 'vs/platform/editor/common/editor'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { FileOperationError, FileOperationResult, IFileService } from 'vs/platform/files/common/files'; +import { FileOperationError, FileOperationResult } from 'vs/platform/files/common/files'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { ILabelService } from 'vs/platform/label/common/label'; @@ -59,7 +59,6 @@ export class PreferencesService extends Disposable implements IPreferencesServic constructor( @IEditorService private readonly editorService: IEditorService, @IEditorGroupsService private readonly editorGroupService: IEditorGroupsService, - @IFileService private readonly fileService: IFileService, @ITextFileService private readonly textFileService: ITextFileService, @IConfigurationService private readonly configurationService: IConfigurationService, @INotificationService private readonly notificationService: INotificationService, @@ -546,7 +545,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic return Promise.resolve(undefined); } - return this.fileService.resolveContent(workspaceConfig) + return this.textFileService.read(workspaceConfig) .then(content => { if (Object.keys(parse(content.value)).indexOf('settings') === -1) { return this.jsonEditingService.write(resource, { key: 'settings', value: {} }, true).then(undefined, () => { }); @@ -558,7 +557,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic } private createIfNotExists(resource: URI, contents: string): Promise { - return this.fileService.resolveContent(resource, { acceptTextOnly: true }).then(undefined, error => { + return this.textFileService.read(resource, { acceptTextOnly: true }).then(undefined, error => { if ((error).fileOperationResult === FileOperationResult.FILE_NOT_FOUND) { return this.textFileService.write(resource, contents).then(undefined, error => { return Promise.reject(new Error(nls.localize('fail.createSettings', "Unable to create '{0}' ({1}).", this.labelService.getUriLabel(resource, { relative: true }), error))); diff --git a/src/vs/workbench/services/textMate/electron-browser/textMateService.ts b/src/vs/workbench/services/textMate/electron-browser/textMateService.ts index 0fd4d880811..94e175490fa 100644 --- a/src/vs/workbench/services/textMate/electron-browser/textMateService.ts +++ b/src/vs/workbench/services/textMate/electron-browser/textMateService.ts @@ -248,8 +248,8 @@ export class TextMateService extends Disposable implements ITextMateService { return null; } try { - const content = await this._fileService.resolveContent(location, { encoding: 'utf8' }); - return parseRawGrammar(content.value, location.path); + const content = await this._fileService.readFile(location); + return parseRawGrammar(content.value.toString(), location.path); } catch (e) { this._logService.error(`Unable to load and parse grammar for scope ${scopeName} from ${location}`, e); return null; diff --git a/src/vs/workbench/services/themes/browser/colorThemeData.ts b/src/vs/workbench/services/themes/browser/colorThemeData.ts index 27806ab7cf1..551806a8ff6 100644 --- a/src/vs/workbench/services/themes/browser/colorThemeData.ts +++ b/src/vs/workbench/services/themes/browser/colorThemeData.ts @@ -297,7 +297,7 @@ function toCSSSelector(extensionId: string, path: string) { function _loadColorTheme(fileService: IFileService, themeLocation: URI, resultRules: ITokenColorizationRule[], resultColors: IColorMap): Promise { if (resources.extname(themeLocation) === '.json') { - return fileService.resolveContent(themeLocation, { encoding: 'utf8' }).then(content => { + return fileService.readFile(themeLocation).then(content => { let errors: Json.ParseError[] = []; let contentValue = Json.parse(content.value.toString(), errors); if (errors.length > 0) { @@ -345,7 +345,7 @@ function _loadColorTheme(fileService: IFileService, themeLocation: URI, resultRu } function _loadSyntaxTokens(fileService: IFileService, themeLocation: URI, resultRules: ITokenColorizationRule[], resultColors: IColorMap): Promise { - return fileService.resolveContent(themeLocation, { encoding: 'utf8' }).then(content => { + return fileService.readFile(themeLocation).then(content => { try { let contentValue = parsePList(content.value.toString()); let settings: ITokenColorizationRule[] = contentValue.settings; diff --git a/src/vs/workbench/services/themes/common/fileIconThemeData.ts b/src/vs/workbench/services/themes/common/fileIconThemeData.ts index 0ee73d56bb9..7d84be48b03 100644 --- a/src/vs/workbench/services/themes/common/fileIconThemeData.ts +++ b/src/vs/workbench/services/themes/common/fileIconThemeData.ts @@ -185,7 +185,7 @@ interface IconThemeDocument extends IconsAssociation { } function _loadIconThemeDocument(fileService: IFileService, location: URI): Promise { - return fileService.resolveContent(location, { encoding: 'utf8' }).then((content) => { + return fileService.readFile(location).then((content) => { let errors: Json.ParseError[] = []; let contentValue = Json.parse(content.value.toString(), errors); if (errors.length > 0 || !contentValue) { diff --git a/src/vs/workbench/services/workspace/electron-browser/workspaceEditingService.ts b/src/vs/workbench/services/workspace/electron-browser/workspaceEditingService.ts index 40d86026557..95f23606581 100644 --- a/src/vs/workbench/services/workspace/electron-browser/workspaceEditingService.ts +++ b/src/vs/workbench/services/workspace/electron-browser/workspaceEditingService.ts @@ -298,8 +298,8 @@ export class WorkspaceEditingService implements IWorkspaceEditingService { } // Read the contents of the workspace file, update it to new location and save it. - const raw = await this.fileService.resolveContent(configPathURI); - const newRawWorkspaceContents = rewriteWorkspaceFileForNewLocation(raw.value, configPathURI, targetConfigPathURI); + const raw = await this.fileService.readFile(configPathURI); + const newRawWorkspaceContents = rewriteWorkspaceFileForNewLocation(raw.value.toString(), configPathURI, targetConfigPathURI); await this.textFileService.create(targetConfigPathURI, newRawWorkspaceContents, { overwrite: true }); } diff --git a/src/vs/workbench/test/workbenchTestServices.ts b/src/vs/workbench/test/workbenchTestServices.ts index 6b7add6c29d..8ec9d49197e 100644 --- a/src/vs/workbench/test/workbenchTestServices.ts +++ b/src/vs/workbench/test/workbenchTestServices.ts @@ -37,7 +37,7 @@ import { IInstantiationService, ServicesAccessor, ServiceIdentifier } from 'vs/p import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService'; import { IWindowsService, IWindowService, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult, MenuBarVisibility, IURIToOpen, IOpenSettings, IWindowConfiguration } from 'vs/platform/windows/common/windows'; import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace'; -import { createTextBufferFactory } from 'vs/editor/common/model/textModel'; +import { createTextBufferFactoryFromStream } from 'vs/editor/common/model/textModel'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService'; @@ -243,15 +243,15 @@ export class TestTextFileService extends BrowserTextFileService { return Promise.reject(error); } - return this.fileService.resolveContent(resource, options).then((content): ITextFileStreamContent => { + return this.fileService.readFileStream(resource, options).then(async (content): Promise => { return { resource: content.resource, name: content.name, mtime: content.mtime, etag: content.etag, - encoding: content.encoding, - value: createTextBufferFactory(content.value), - size: content.value.length + encoding: 'utf8', + value: await createTextBufferFactoryFromStream(content.value), + size: 10 }; }); }