mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-14 07:54:36 +01:00
createFile and createFolder only allow single operation until there are more use cases
This commit is contained in:
@@ -120,9 +120,9 @@ class CreateOperation implements IFileOperation {
|
||||
return new Noop(); // not overwriting, but ignoring, and the target file exists
|
||||
}
|
||||
if (this.options.folder) {
|
||||
await this._workingCopyFileService.createFolder([{ resource: this.newUri }], this.undoRedoInfo, token);
|
||||
await this._workingCopyFileService.createFolder({ resource: this.newUri }, this.undoRedoInfo, token);
|
||||
} else {
|
||||
await this._workingCopyFileService.create([{ resource: this.newUri, contents: this.contents, overwrite: this.options.overwrite }], this.undoRedoInfo, token);
|
||||
await this._workingCopyFileService.create({ resource: this.newUri, contents: this.contents, overwrite: this.options.overwrite }, this.undoRedoInfo, token);
|
||||
}
|
||||
return this._instaService.createInstance(DeleteOperation, this.newUri, this.options, { isUndoing: true }, !this.options.folder && !this.contents);
|
||||
}
|
||||
|
||||
@@ -151,8 +151,7 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
|
||||
async create(resource: URI, value?: string | ITextSnapshot, options?: ICreateFileOptions): Promise<IFileStatWithMetadata> {
|
||||
const readable = await this.getEncodedReadable(resource, value);
|
||||
|
||||
const result = await this.workingCopyFileService.create([{ resource, contents: readable, overwrite: options?.overwrite }]);
|
||||
return result[0];
|
||||
return await this.workingCopyFileService.create({ resource, contents: readable, overwrite: options?.overwrite });
|
||||
}
|
||||
|
||||
async write(resource: URI, value: string | ITextSnapshot, options?: IWriteTextFileOptions): Promise<IFileStatWithMetadata> {
|
||||
|
||||
@@ -164,7 +164,7 @@ export interface IWorkingCopyFileService {
|
||||
* Working copy owners can listen to the `onWillRunWorkingCopyFileOperation` and
|
||||
* `onDidRunWorkingCopyFileOperation` events to participate.
|
||||
*/
|
||||
create(operations: ICreateFileOperation[], undoInfo?: IFileOperationUndoRedoInfo, token?: CancellationToken): Promise<IFileStatWithMetadata[]>;
|
||||
create(operation: ICreateFileOperation, undoInfo?: IFileOperationUndoRedoInfo, token?: CancellationToken): Promise<IFileStatWithMetadata>;
|
||||
|
||||
/**
|
||||
* Will create a folder and any parent folder that needs to be created.
|
||||
@@ -175,7 +175,7 @@ export interface IWorkingCopyFileService {
|
||||
* Note: events will only be emitted for the provided resource, but not any
|
||||
* parent folders that are being created as part of the operation.
|
||||
*/
|
||||
createFolder(operations: ICreateOperation[], undoInfo?: IFileOperationUndoRedoInfo, token?: CancellationToken): Promise<IFileStatWithMetadata[]>;
|
||||
createFolder(operation: ICreateOperation, undoInfo?: IFileOperationUndoRedoInfo, token?: CancellationToken): Promise<IFileStatWithMetadata>;
|
||||
|
||||
/**
|
||||
* Will move working copies matching the provided resources and corresponding children
|
||||
@@ -271,12 +271,12 @@ export class WorkingCopyFileService extends Disposable implements IWorkingCopyFi
|
||||
|
||||
//#region File operations
|
||||
|
||||
create(operations: ICreateFileOperation[], undoInfo?: IFileOperationUndoRedoInfo, token?: CancellationToken): Promise<IFileStatWithMetadata[]> {
|
||||
return Promise.all(operations.map(o => this.doCreateFileOrFolder(o, true, undoInfo, token)));
|
||||
create(operation: ICreateFileOperation, undoInfo?: IFileOperationUndoRedoInfo, token?: CancellationToken): Promise<IFileStatWithMetadata> {
|
||||
return this.doCreateFileOrFolder(operation, true, undoInfo, token);
|
||||
}
|
||||
|
||||
createFolder(operations: ICreateOperation[], undoInfo?: IFileOperationUndoRedoInfo, token?: CancellationToken): Promise<IFileStatWithMetadata[]> {
|
||||
return Promise.all(operations.map(o => this.doCreateFileOrFolder(o, false, undoInfo, token)));
|
||||
createFolder(operation: ICreateOperation, undoInfo?: IFileOperationUndoRedoInfo, token?: CancellationToken): Promise<IFileStatWithMetadata> {
|
||||
return this.doCreateFileOrFolder(operation, false, undoInfo, token);
|
||||
}
|
||||
|
||||
async doCreateFileOrFolder(operation: ICreateFileOperation | ICreateOperation, isFile: boolean, undoInfo?: IFileOperationUndoRedoInfo, token?: CancellationToken): Promise<IFileStatWithMetadata> {
|
||||
|
||||
@@ -224,7 +224,7 @@ suite('WorkingCopyFileService', () => {
|
||||
eventCounter++;
|
||||
});
|
||||
|
||||
await accessor.workingCopyFileService.createFolder([{ resource }]);
|
||||
await accessor.workingCopyFileService.createFolder({ resource });
|
||||
|
||||
assert.equal(eventCounter, 3);
|
||||
|
||||
@@ -459,7 +459,7 @@ suite('WorkingCopyFileService', () => {
|
||||
eventCounter++;
|
||||
});
|
||||
|
||||
await accessor.workingCopyFileService.create([{ resource, contents }]);
|
||||
await accessor.workingCopyFileService.create({ resource, contents });
|
||||
assert.ok(!accessor.workingCopyService.isDirty(model.resource));
|
||||
model.dispose();
|
||||
|
||||
|
||||
@@ -103,10 +103,8 @@ suite('MainThreadEditors', () => {
|
||||
});
|
||||
services.set(IWorkingCopyFileService, new class extends mock<IWorkingCopyFileService>() {
|
||||
onDidRunWorkingCopyFileOperation = Event.None;
|
||||
create(operations: ICreateFileOperation[]) {
|
||||
for (const operation of operations) {
|
||||
createdResources.add(operation.resource);
|
||||
}
|
||||
create(operation: ICreateFileOperation) {
|
||||
createdResources.add(operation.resource);
|
||||
return Promise.resolve(Object.create(null));
|
||||
}
|
||||
move(operations: IMoveOperation[]) {
|
||||
|
||||
@@ -201,8 +201,8 @@ export class TestWorkingCopyFileService implements IWorkingCopyFileService {
|
||||
|
||||
getDirty(resource: URI): IWorkingCopy[] { return []; }
|
||||
|
||||
create(operations: ICreateFileOperation[], undoInfo?: IFileOperationUndoRedoInfo, token?: CancellationToken): Promise<IFileStatWithMetadata[]> { throw new Error('Method not implemented.'); }
|
||||
createFolder(operations: ICreateOperation[], undoInfo?: IFileOperationUndoRedoInfo, token?: CancellationToken): Promise<IFileStatWithMetadata[]> { throw new Error('Method not implemented.'); }
|
||||
create(operation: ICreateFileOperation, undoInfo?: IFileOperationUndoRedoInfo, token?: CancellationToken): Promise<IFileStatWithMetadata> { throw new Error('Method not implemented.'); }
|
||||
createFolder(operation: ICreateOperation, undoInfo?: IFileOperationUndoRedoInfo, token?: CancellationToken): Promise<IFileStatWithMetadata> { throw new Error('Method not implemented.'); }
|
||||
|
||||
move(operations: IMoveOperation[], undoInfo?: IFileOperationUndoRedoInfo): Promise<IFileStatWithMetadata[]> { throw new Error('Method not implemented.'); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user