Skip to content

Commit

Permalink
use new VSBuffer based api, #91383
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Jun 23, 2020
1 parent 657349b commit 7764a48
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/vs/workbench/services/bulkEdit/browser/bulkFileEdits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ 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[];
Expand Down Expand Up @@ -55,7 +56,7 @@ class CreateOperation implements IFileOperation {
constructor(
readonly newUri: URI,
readonly options: WorkspaceFileEditOptions,
readonly contents: string | undefined,
readonly contents: VSBuffer | undefined,
@IFileService private readonly _fileService: IFileService,
@ITextFileService private readonly _textFileService: ITextFileService,
@IInstantiationService private readonly _instaService: IInstantiationService,
Expand All @@ -70,7 +71,6 @@ class CreateOperation implements IFileOperation {
if (this.options.overwrite === undefined && this.options.ignoreIfExists && await this._fileService.exists(this.newUri)) {
return new Noop(); // not overwriting, but ignoring, and the target file exists
}
//todo@jrieken, @bpasero allow to accept VSBuffer
await this._textFileService.create(this.newUri, this.contents, { overwrite: this.options.overwrite });
return this._instaService.createInstance(DeleteOperation, this.newUri, this.options);
}
Expand All @@ -83,7 +83,6 @@ 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,
Expand All @@ -102,9 +101,9 @@ class DeleteOperation implements IFileOperation {
return new Noop();
}

let contents: string | undefined;
let contents: VSBuffer | undefined;
try {
contents = (await this._textFileService.read(this.oldUri)).value;
contents = (await this._fileService.readFile(this.oldUri)).value;
} catch (err) {
this._logService.critical(err);
}
Expand Down

0 comments on commit 7764a48

Please sign in to comment.