提交 e8fb4fd3 编写于 作者: I isidor

bulkFileEdits: use textFileService only for creating empty files

上级 8ae693be
......@@ -8,7 +8,7 @@ import { WorkspaceFileEditOptions } from 'vs/editor/common/modes';
import { IFileService, FileSystemProviderCapabilities, IFileContent } from 'vs/platform/files/common/files';
import { IProgress } from 'vs/platform/progress/common/progress';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IWorkingCopyFileService, IFileOperationUndoRedoInfo, IMoveOperation, ICopyOperation, IDeleteOperation, ICreateOperation } from 'vs/workbench/services/workingCopy/common/workingCopyFileService';
import { IWorkingCopyFileService, IFileOperationUndoRedoInfo, IMoveOperation, ICopyOperation, IDeleteOperation, ICreateOperation, ICreateFileOperation } from 'vs/workbench/services/workingCopy/common/workingCopyFileService';
import { IWorkspaceUndoRedoElement, UndoRedoElementType, IUndoRedoService, UndoRedoGroup, UndoRedoSource } from 'vs/platform/undoRedo/common/undoRedo';
import { URI } from 'vs/base/common/uri';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
......@@ -170,7 +170,8 @@ class CreateOperation implements IFileOperation {
async perform(token: CancellationToken): Promise<IFileOperation> {
const folderCreates: ICreateOperation[] = [];
const fileCreates: { resource: URI, value?: string | ITextSnapshot, options?: { overwrite?: boolean } }[] = [];
const fileCreates: ICreateFileOperation[] = [];
const emptyFileCreates: { resource: URI, value?: string | ITextSnapshot, options?: { overwrite?: boolean } }[] = [];
const undoes: DeleteEdit[] = [];
for (const edit of this._edits) {
......@@ -179,18 +180,21 @@ class CreateOperation implements IFileOperation {
}
if (edit.options.folder) {
folderCreates.push({ resource: edit.newUri });
} else if (edit.contents) {
fileCreates.push({ resource: edit.newUri, contents: edit.contents, overwrite: edit.options.overwrite });
} else {
fileCreates.push({ resource: edit.newUri, value: edit.contents?.toString(), options: { overwrite: edit.options.overwrite } });
emptyFileCreates.push({ resource: edit.newUri, value: edit.contents, options: { overwrite: edit.options.overwrite } });
}
undoes.push(new DeleteEdit(edit.newUri, edit.options, !edit.options.folder && !edit.contents));
}
if (fileCreates.length === 0 && folderCreates.length === 0) {
if (emptyFileCreates.length === 0 && folderCreates.length === 0 && fileCreates.length === 0) {
return new Noop();
}
await this._workingCopyFileService.createFolder(folderCreates, this._undoRedoInfo, token);
await this._textFileService.create(fileCreates, this._undoRedoInfo, token);
await this._workingCopyFileService.create(fileCreates, this._undoRedoInfo, token);
await this._textFileService.create(emptyFileCreates, this._undoRedoInfo, token);
return this._instaService.createInstance(DeleteOperation, undoes, { isUndoing: true });
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册