Skip to content

Commit

Permalink
tweak events and add some jsdoc, #43768
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Nov 18, 2019
1 parent b9ba645 commit c977eb6
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 20 deletions.
53 changes: 39 additions & 14 deletions src/vs/vscode.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -825,46 +825,71 @@ declare module 'vscode' {
//#region mjbvz,joh: https://github.com/Microsoft/vscode/issues/43768

export interface FileCreateEvent {
readonly created: ReadonlyArray<Uri>;

/**
* The files that got created.
*/
readonly files: ReadonlyArray<Uri>;
}

export interface FileWillCreateEvent {
readonly creating: ReadonlyArray<Uri>;
waitUntil(thenable: Thenable<any>): void;

/**
* The files that are going to be created.
*/
readonly files: ReadonlyArray<Uri>;

waitUntil(thenable: Thenable<WorkspaceEdit>): void;
waitUntil(thenable: Thenable<any>): void;
}

export interface FileDeleteEvent {
readonly deleted: ReadonlyArray<Uri>;

/**
* The files that got deleted.
*/
readonly files: ReadonlyArray<Uri>;
}

export interface FileWillDeleteEvent {
readonly deleting: ReadonlyArray<Uri>;
waitUntil(thenable: Thenable<any>): void;

/**
* The files that are going to be deleted.
*/
readonly files: ReadonlyArray<Uri>;

waitUntil(thenable: Thenable<WorkspaceEdit>): void;
waitUntil(thenable: Thenable<any>): void;
}

export interface FileRenameEvent {
readonly renamed: ReadonlyArray<{ oldUri: Uri, newUri: Uri }>;

/**
* The files that got renamed.
*/
readonly files: ReadonlyArray<{ oldUri: Uri, newUri: Uri }>;
}

export interface FileWillRenameEvent {
readonly renaming: ReadonlyArray<{ oldUri: Uri, newUri: Uri }>;
waitUntil(thenable: Thenable<any>): void;

/**
* The files that are going to be renamed.
*/
readonly files: ReadonlyArray<{ oldUri: Uri, newUri: Uri }>;

waitUntil(thenable: Thenable<WorkspaceEdit>): void;
waitUntil(thenable: Thenable<any>): void;
}

export namespace workspace {

export const onWillCreateFiles: Event<FileWillCreateEvent>;
export const onDidCreateFiles: Event<FileCreateEvent>;

export const onWillDeleteFiles: Event<FileWillDeleteEvent>;
export const onDidDeleteFiles: Event<FileDeleteEvent>;

export const onWillRenameFiles: Event<FileWillRenameEvent>;
export const onDidRenameFiles: Event<FileRenameEvent>;

export const onDidCreateFiles: Event<FileCreateEvent>;
export const onDidDeleteFiles: Event<FileDeleteEvent>;
export const onDidRenameFiles: Event<FileRenameEvent>;
}
//#endregion

Expand Down
12 changes: 6 additions & 6 deletions src/vs/workbench/api/common/extHostFileSystemEventService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ export class ExtHostFileSystemEventService implements ExtHostFileSystemEventServ
$onDidRunFileOperation(operation: FileOperation, target: UriComponents, source: UriComponents | undefined): void {
switch (operation) {
case FileOperation.MOVE:
this._onDidRenameFile.fire(Object.freeze({ renamed: [{ oldUri: URI.revive(source!), newUri: URI.revive(target) }] }));
this._onDidRenameFile.fire(Object.freeze({ files: [{ oldUri: URI.revive(source!), newUri: URI.revive(target) }] }));
break;
case FileOperation.DELETE:
this._onDidDeleteFile.fire(Object.freeze({ deleted: [URI.revive(target)] }));
this._onDidDeleteFile.fire(Object.freeze({ files: [URI.revive(target)] }));
break;
case FileOperation.CREATE:
this._onDidCreateFile.fire(Object.freeze({ created: [URI.revive(target)] }));
this._onDidCreateFile.fire(Object.freeze({ files: [URI.revive(target)] }));
break;
default:
//ignore, dont send
Expand Down Expand Up @@ -179,13 +179,13 @@ export class ExtHostFileSystemEventService implements ExtHostFileSystemEventServ
async $onWillRunFileOperation(operation: FileOperation, target: UriComponents, source: UriComponents | undefined): Promise<any> {
switch (operation) {
case FileOperation.MOVE:
await this._fireWillEvent(this._onWillRenameFile, { renaming: [{ oldUri: URI.revive(source!), newUri: URI.revive(target) }], });
await this._fireWillEvent(this._onWillRenameFile, { files: [{ oldUri: URI.revive(source!), newUri: URI.revive(target) }], });
break;
case FileOperation.DELETE:
await this._fireWillEvent(this._onWillDeleteFile, { deleting: [URI.revive(target)] });
await this._fireWillEvent(this._onWillDeleteFile, { files: [URI.revive(target)] });
break;
case FileOperation.CREATE:
await this._fireWillEvent(this._onWillCreateFile, { creating: [URI.revive(target)] });
await this._fireWillEvent(this._onWillCreateFile, { files: [URI.revive(target)] });
break;
default:
//ignore, dont send
Expand Down

0 comments on commit c977eb6

Please sign in to comment.