diff --git a/src/vs/workbench/services/bulkEdit/browser/bulkFileEdits.ts b/src/vs/workbench/services/bulkEdit/browser/bulkFileEdits.ts index d23d565ea7e012e4eeef7a29b447db30aa64e436..10ad7979aa0893f5e7f64dc4734c4922ff438475 100644 --- a/src/vs/workbench/services/bulkEdit/browser/bulkFileEdits.ts +++ b/src/vs/workbench/services/bulkEdit/browser/bulkFileEdits.ts @@ -14,7 +14,6 @@ import { IWorkspaceUndoRedoElement, UndoRedoElementType, IUndoRedoService } from import { URI } from 'vs/base/common/uri'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { ILogService } from 'vs/platform/log/common/log'; -import { VSBuffer } from 'vs/base/common/buffer'; interface IFileOperation { uris: URI[]; @@ -55,7 +54,7 @@ class CreateOperation implements IFileOperation { constructor( readonly newUri: URI, readonly options: WorkspaceFileEditOptions, - readonly contents: VSBuffer | undefined, + readonly contents: string | undefined, @IFileService private readonly _fileService: IFileService, @ITextFileService private readonly _textFileService: ITextFileService, @IInstantiationService private readonly _instaService: IInstantiationService, @@ -82,9 +81,10 @@ class DeleteOperation implements IFileOperation { readonly options: WorkspaceFileEditOptions, @IWorkingCopyFileService private readonly _workingCopyFileService: IWorkingCopyFileService, @IFileService private readonly _fileService: IFileService, + @ITextFileService private readonly _textFileService: ITextFileService, @IConfigurationService private readonly _configurationService: IConfigurationService, @IInstantiationService private readonly _instaService: IInstantiationService, - @ILogService private readonly _logService: ILogService, + @ILogService private readonly _logService: ILogService ) { } get uris() { @@ -100,9 +100,9 @@ class DeleteOperation implements IFileOperation { return new Noop(); } - let contents: VSBuffer | undefined; + let contents: string | undefined; try { - contents = (await this._fileService.readFile(this.oldUri)).value; + contents = (await this._textFileService.read(this.oldUri)).value; } catch (err) { this._logService.critical(err); } diff --git a/src/vs/workbench/services/textfile/browser/textFileService.ts b/src/vs/workbench/services/textfile/browser/textFileService.ts index 1f60e61aa8dcc24b31d9dd50b179213846ffffcc..72233647e2d4f8f6c334d4f00e9f2de4dcf48326 100644 --- a/src/vs/workbench/services/textfile/browser/textFileService.ts +++ b/src/vs/workbench/services/textfile/browser/textFileService.ts @@ -152,7 +152,7 @@ export abstract class AbstractTextFileService extends Disposable implements ITex } } - async create(resource: URI, value?: string | ITextSnapshot | VSBuffer, options?: ICreateFileOptions): Promise { + async create(resource: URI, value?: string | ITextSnapshot, options?: ICreateFileOptions): Promise { // file operation participation await this.workingCopyFileService.runFileOperationParticipants([{ target: resource, source: undefined }], FileOperation.CREATE); @@ -175,8 +175,8 @@ export abstract class AbstractTextFileService extends Disposable implements ITex return stat; } - protected doCreate(resource: URI, value?: string | ITextSnapshot | VSBuffer, options?: ICreateFileOptions): Promise { - return this.fileService.createFile(resource, value instanceof VSBuffer ? value : toBufferOrReadable(value), options); + protected doCreate(resource: URI, value?: string | ITextSnapshot, options?: ICreateFileOptions): Promise { + return this.fileService.createFile(resource, toBufferOrReadable(value), options); } async write(resource: URI, value: string | ITextSnapshot, options?: IWriteTextFileOptions): Promise { diff --git a/src/vs/workbench/services/textfile/common/textfiles.ts b/src/vs/workbench/services/textfile/common/textfiles.ts index 48a490bb4871cbfcd07d514a49fcf824df99c46c..e4528b1e8b6c67c1a817ed728690286aa85eb9cd 100644 --- a/src/vs/workbench/services/textfile/common/textfiles.ts +++ b/src/vs/workbench/services/textfile/common/textfiles.ts @@ -104,7 +104,7 @@ export interface ITextFileService extends IDisposable { * Create a file. If the file exists it will be overwritten with the contents if * the options enable to overwrite. */ - create(resource: URI, contents?: string | ITextSnapshot | VSBuffer, options?: { overwrite?: boolean }): Promise; + create(resource: URI, contents?: string | ITextSnapshot, options?: { overwrite?: boolean }): Promise; } export interface IReadTextFileOptions extends IReadFileOptions { diff --git a/src/vs/workbench/services/textfile/test/electron-browser/textFileService.io.test.ts b/src/vs/workbench/services/textfile/test/electron-browser/textFileService.io.test.ts index 0690e162cda8542bc71c44248a8e0da4e2fc5529..72e964fd95e147978d8162ec354c70d621c5feca 100644 --- a/src/vs/workbench/services/textfile/test/electron-browser/textFileService.io.test.ts +++ b/src/vs/workbench/services/textfile/test/electron-browser/textFileService.io.test.ts @@ -27,7 +27,6 @@ import { isWindows } from 'vs/base/common/platform'; import { readFileSync, statSync } from 'fs'; import { detectEncodingByBOM } from 'vs/workbench/services/textfile/test/node/encoding/encoding.test'; import { workbenchInstantiationService, TestNativeTextFileServiceWithEncodingOverrides } from 'vs/workbench/test/electron-browser/workbenchTestServices'; -import { VSBuffer } from 'vs/base/common/buffer'; suite('Files - TextFileService i/o', function () { const parentDir = getRandomTestPath(tmpdir(), 'vsctests', 'textfileservice'); @@ -101,15 +100,6 @@ suite('Files - TextFileService i/o', function () { assert.equal((await readFile(resource.fsPath)).toString(), 'Hello World'); }); - test('create - no encoding - content provided (VSBuffer)', async () => { - const resource = URI.file(join(testDir, 'small_new.txt')); - - await service.create(resource, VSBuffer.fromString('Hello World')); - - assert.equal(await exists(resource.fsPath), true); - assert.equal((await readFile(resource.fsPath)).toString(), 'Hello World'); - }); - test('create - UTF 16 LE - no content', async () => { const resource = URI.file(join(testDir, 'small_new.utf16le'));