未验证 提交 d57b8538 编写于 作者: J Johannes Rieken 提交者: GitHub

Merge pull request #85830 from microsoft/joh/finalWill

Finalize onWill|DidCreate|Rename|DeleteFile apis
......@@ -8084,6 +8084,172 @@ declare module 'vscode' {
waitUntil(thenable: Thenable<any>): void;
}
/**
* An event that is fired when files are going to be created.
*
* To make modifications to the workspace before the files are created,
* call the [`waitUntil](#FileWillCreateEvent.waitUntil)-function with a
* thenable that resolves to a [workspace edit](#WorkspaceEdit).
*/
export interface FileWillCreateEvent {
/**
* The files that are going to be created.
*/
readonly files: ReadonlyArray<Uri>;
/**
* Allows to pause the event and to apply a [workspace edit](#WorkspaceEdit).
*
* *Note:* This function can only be called during event dispatch and not
* in an asynchronous manner:
*
* ```ts
* workspace.onWillCreateFiles(event => {
* // async, will *throw* an error
* setTimeout(() => event.waitUntil(promise));
*
* // sync, OK
* event.waitUntil(promise);
* })
* ```
*
* @param thenable A thenable that delays saving.
*/
waitUntil(thenable: Thenable<WorkspaceEdit>): void;
/**
* Allows to pause the event until the provided thenable resolves.
*
* *Note:* This function can only be called during event dispatch.
*
* @param thenable A thenable that delays saving.
*/
waitUntil(thenable: Thenable<any>): void;
}
/**
* An event that is fired after files are created.
*/
export interface FileCreateEvent {
/**
* The files that got created.
*/
readonly files: ReadonlyArray<Uri>;
}
/**
* An event that is fired when files are going to be deleted.
*
* To make modifications to the workspace before the files are deleted,
* call the [`waitUntil](#FileWillCreateEvent.waitUntil)-function with a
* thenable that resolves to a [workspace edit](#WorkspaceEdit).
*/
export interface FileWillDeleteEvent {
/**
* The files that are going to be deleted.
*/
readonly files: ReadonlyArray<Uri>;
/**
* Allows to pause the event and to apply a [workspace edit](#WorkspaceEdit).
*
* *Note:* This function can only be called during event dispatch and not
* in an asynchronous manner:
*
* ```ts
* workspace.onWillCreateFiles(event => {
* // async, will *throw* an error
* setTimeout(() => event.waitUntil(promise));
*
* // sync, OK
* event.waitUntil(promise);
* })
* ```
*
* @param thenable A thenable that delays saving.
*/
waitUntil(thenable: Thenable<WorkspaceEdit>): void;
/**
* Allows to pause the event until the provided thenable resolves.
*
* *Note:* This function can only be called during event dispatch.
*
* @param thenable A thenable that delays saving.
*/
waitUntil(thenable: Thenable<any>): void;
}
/**
* An event that is fired after files are deleted.
*/
export interface FileDeleteEvent {
/**
* The files that got deleted.
*/
readonly files: ReadonlyArray<Uri>;
}
/**
* An event that is fired when files are going to be renamed.
*
* To make modifications to the workspace before the files are renamed,
* call the [`waitUntil](#FileWillCreateEvent.waitUntil)-function with a
* thenable that resolves to a [workspace edit](#WorkspaceEdit).
*/
export interface FileWillRenameEvent {
/**
* The files that are going to be renamed.
*/
readonly files: ReadonlyArray<{ oldUri: Uri, newUri: Uri }>;
/**
* Allows to pause the event and to apply a [workspace edit](#WorkspaceEdit).
*
* *Note:* This function can only be called during event dispatch and not
* in an asynchronous manner:
*
* ```ts
* workspace.onWillCreateFiles(event => {
* // async, will *throw* an error
* setTimeout(() => event.waitUntil(promise));
*
* // sync, OK
* event.waitUntil(promise);
* })
* ```
*
* @param thenable A thenable that delays saving.
*/
waitUntil(thenable: Thenable<WorkspaceEdit>): void;
/**
* Allows to pause the event until the provided thenable resolves.
*
* *Note:* This function can only be called during event dispatch.
*
* @param thenable A thenable that delays saving.
*/
waitUntil(thenable: Thenable<any>): void;
}
/**
* An event that is fired after files are renamed.
*/
export interface FileRenameEvent {
/**
* The files that got renamed.
*/
readonly files: ReadonlyArray<{ oldUri: Uri, newUri: Uri }>;
}
/**
* An event describing a change to the set of [workspace folders](#workspace.workspaceFolders).
*/
......@@ -8433,6 +8599,76 @@ declare module 'vscode' {
*/
export const onDidSaveTextDocument: Event<TextDocument>;
/**
* An event that is emitted when files are being created.
*
* *Note 1:* This event is triggered by user gestures, like creating a file from the
* explorer, or from the [`workspace.applyEdit`](#workspace.applyEdit)-api. This event is *not* fired when
* files change on disk, e.g triggered by another application, or when using the
* [`workspace.fs`](#FileSystem)-api.
*
* *Note 2:* When this event is fired, edits to files thare are being created cannot be applied.
*/
export const onWillCreateFiles: Event<FileWillCreateEvent>;
/**
* An event that is emitted when files have been created.
*
* *Note:* This event is triggered by user gestures, like creating a file from the
* explorer, or from the [`workspace.applyEdit`](#workspace.applyEdit)-api, but this event is *not* fired when
* files change on disk, e.g triggered by another application, or when using the
* [`workspace.fs`](#FileSystem)-api.
*/
export const onDidCreateFiles: Event<FileCreateEvent>;
/**
* An event that is emitted when files are being deleted.
*
* *Note 1:* This event is triggered by user gestures, like deleting a file from the
* explorer, or from the [`workspace.applyEdit`](#workspace.applyEdit)-api, but this event is *not* fired when
* files change on disk, e.g triggered by another application, or when using the
* [`workspace.fs`](#FileSystem)-api.
*
* *Note 2:* When deleting a folder with children only one event is fired.
*/
export const onWillDeleteFiles: Event<FileWillDeleteEvent>;
/**
* An event that is emitted when files have been deleted.
*
* *Note 1:* This event is triggered by user gestures, like deleting a file from the
* explorer, or from the [`workspace.applyEdit`](#workspace.applyEdit)-api, but this event is *not* fired when
* files change on disk, e.g triggered by another application, or when using the
* [`workspace.fs`](#FileSystem)-api.
*
* *Note 2:* When deleting a folder with children only one event is fired.
*/
export const onDidDeleteFiles: Event<FileDeleteEvent>;
/**
* An event that is emitted when files are being renamed.
*
* *Note 1:* This event is triggered by user gestures, like renaming a file from the
* explorer, and from the [`workspace.applyEdit`](#workspace.applyEdit)-api, but this event is *not* fired when
* files change on disk, e.g triggered by another application, or when using the
* [`workspace.fs`](#FileSystem)-api.
*
* *Note 2:* When renaming a folder with children only one event is fired.
*/
export const onWillRenameFiles: Event<FileWillRenameEvent>;
/**
* An event that is emitted when files have been renamed.
*
* *Note 1:* This event is triggered by user gestures, like renaming a file from the
* explorer, and from the [`workspace.applyEdit`](#workspace.applyEdit)-api, but this event is *not* fired when
* files change on disk, e.g triggered by another application, or when using the
* [`workspace.fs`](#FileSystem)-api.
*
* *Note 2:* When renaming a folder with children only one event is fired.
*/
export const onDidRenameFiles: Event<FileRenameEvent>;
/**
* Get a workspace configuration object.
*
......
......@@ -961,247 +961,6 @@ declare module 'vscode' {
//#endregion
//#region mjbvz,joh: https://github.com/Microsoft/vscode/issues/43768
/**
* An event that is fired when files are going to be created.
*
* To make modifications to the workspace before the files are created,
* call the [`waitUntil](#FileWillCreateEvent.waitUntil)-function with a
* thenable that resolves to a [workspace edit](#WorkspaceEdit).
*/
export interface FileWillCreateEvent {
/**
* The files that are going to be created.
*/
readonly files: ReadonlyArray<Uri>;
/**
* Allows to pause the event and to apply a [workspace edit](#WorkspaceEdit).
*
* *Note:* This function can only be called during event dispatch and not
* in an asynchronous manner:
*
* ```ts
* workspace.onWillCreateFiles(event => {
* // async, will *throw* an error
* setTimeout(() => event.waitUntil(promise));
*
* // sync, OK
* event.waitUntil(promise);
* })
* ```
*
* @param thenable A thenable that delays saving.
*/
waitUntil(thenable: Thenable<WorkspaceEdit>): void;
/**
* Allows to pause the event until the provided thenable resolves.
*
* *Note:* This function can only be called during event dispatch.
*
* @param thenable A thenable that delays saving.
*/
waitUntil(thenable: Thenable<any>): void;
}
/**
* An event that is fired after files are created.
*/
export interface FileCreateEvent {
/**
* The files that got created.
*/
readonly files: ReadonlyArray<Uri>;
}
/**
* An event that is fired when files are going to be deleted.
*
* To make modifications to the workspace before the files are deleted,
* call the [`waitUntil](#FileWillCreateEvent.waitUntil)-function with a
* thenable that resolves to a [workspace edit](#WorkspaceEdit).
*/
export interface FileWillDeleteEvent {
/**
* The files that are going to be deleted.
*/
readonly files: ReadonlyArray<Uri>;
/**
* Allows to pause the event and to apply a [workspace edit](#WorkspaceEdit).
*
* *Note:* This function can only be called during event dispatch and not
* in an asynchronous manner:
*
* ```ts
* workspace.onWillCreateFiles(event => {
* // async, will *throw* an error
* setTimeout(() => event.waitUntil(promise));
*
* // sync, OK
* event.waitUntil(promise);
* })
* ```
*
* @param thenable A thenable that delays saving.
*/
waitUntil(thenable: Thenable<WorkspaceEdit>): void;
/**
* Allows to pause the event until the provided thenable resolves.
*
* *Note:* This function can only be called during event dispatch.
*
* @param thenable A thenable that delays saving.
*/
waitUntil(thenable: Thenable<any>): void;
}
/**
* An event that is fired after files are deleted.
*/
export interface FileDeleteEvent {
/**
* The files that got deleted.
*/
readonly files: ReadonlyArray<Uri>;
}
/**
* An event that is fired when files are going to be renamed.
*
* To make modifications to the workspace before the files are renamed,
* call the [`waitUntil](#FileWillCreateEvent.waitUntil)-function with a
* thenable that resolves to a [workspace edit](#WorkspaceEdit).
*/
export interface FileWillRenameEvent {
/**
* The files that are going to be renamed.
*/
readonly files: ReadonlyArray<{ oldUri: Uri, newUri: Uri }>;
/**
* Allows to pause the event and to apply a [workspace edit](#WorkspaceEdit).
*
* *Note:* This function can only be called during event dispatch and not
* in an asynchronous manner:
*
* ```ts
* workspace.onWillCreateFiles(event => {
* // async, will *throw* an error
* setTimeout(() => event.waitUntil(promise));
*
* // sync, OK
* event.waitUntil(promise);
* })
* ```
*
* @param thenable A thenable that delays saving.
*/
waitUntil(thenable: Thenable<WorkspaceEdit>): void;
/**
* Allows to pause the event until the provided thenable resolves.
*
* *Note:* This function can only be called during event dispatch.
*
* @param thenable A thenable that delays saving.
*/
waitUntil(thenable: Thenable<any>): void;
}
/**
* An event that is fired after files are renamed.
*/
export interface FileRenameEvent {
/**
* The files that got renamed.
*/
readonly files: ReadonlyArray<{ oldUri: Uri, newUri: Uri }>;
}
export namespace workspace {
/**
* An event that is emitted when files are being created.
*
* *Note 1:* This event is triggered by user gestures, like creating a file from the
* explorer, or from the [`workspace.applyEdit`](#workspace.applyEdit)-api. This event is *not* fired when
* files change on disk, e.g triggered by another application, or when using the
* [`workspace.fs`](#FileSystem)-api.
*
* *Note 2:* When this event is fired, edits to files thare are being created cannot be applied.
*/
export const onWillCreateFiles: Event<FileWillCreateEvent>;
/**
* An event that is emitted when files have been created.
*
* *Note:* This event is triggered by user gestures, like creating a file from the
* explorer, or from the [`workspace.applyEdit`](#workspace.applyEdit)-api, but this event is *not* fired when
* files change on disk, e.g triggered by another application, or when using the
* [`workspace.fs`](#FileSystem)-api.
*/
export const onDidCreateFiles: Event<FileCreateEvent>;
/**
* An event that is emitted when files are being deleted.
*
* *Note 1:* This event is triggered by user gestures, like deleting a file from the
* explorer, or from the [`workspace.applyEdit`](#workspace.applyEdit)-api, but this event is *not* fired when
* files change on disk, e.g triggered by another application, or when using the
* [`workspace.fs`](#FileSystem)-api.
*
* *Note 2:* When deleting a folder with children only one event is fired.
*/
export const onWillDeleteFiles: Event<FileWillDeleteEvent>;
/**
* An event that is emitted when files have been deleted.
*
* *Note 1:* This event is triggered by user gestures, like deleting a file from the
* explorer, or from the [`workspace.applyEdit`](#workspace.applyEdit)-api, but this event is *not* fired when
* files change on disk, e.g triggered by another application, or when using the
* [`workspace.fs`](#FileSystem)-api.
*
* *Note 2:* When deleting a folder with children only one event is fired.
*/
export const onDidDeleteFiles: Event<FileDeleteEvent>;
/**
* An event that is emitted when files are being renamed.
*
* *Note 1:* This event is triggered by user gestures, like renaming a file from the
* explorer, and from the [`workspace.applyEdit`](#workspace.applyEdit)-api, but this event is *not* fired when
* files change on disk, e.g triggered by another application, or when using the
* [`workspace.fs`](#FileSystem)-api.
*
* *Note 2:* When renaming a folder with children only one event is fired.
*/
export const onWillRenameFiles: Event<FileWillRenameEvent>;
/**
* An event that is emitted when files have been renamed.
*
* *Note 1:* This event is triggered by user gestures, like renaming a file from the
* explorer, and from the [`workspace.applyEdit`](#workspace.applyEdit)-api, but this event is *not* fired when
* files change on disk, e.g triggered by another application, or when using the
* [`workspace.fs`](#FileSystem)-api.
*
* *Note 2:* When renaming a folder with children only one event is fired.
*/
export const onDidRenameFiles: Event<FileRenameEvent>;
}
//#endregion
//#region Alex - OnEnter enhancement
export interface OnEnterRule {
/**
......
......@@ -699,27 +699,21 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
return extHostLabelService.$registerResourceLabelFormatter(formatter);
},
onDidCreateFiles: (listener, thisArg, disposables) => {
checkProposedApiEnabled(extension);
return extHostFileSystemEvent.onDidCreateFile(listener, thisArg, disposables);
},
onDidDeleteFiles: (listener, thisArg, disposables) => {
checkProposedApiEnabled(extension);
return extHostFileSystemEvent.onDidDeleteFile(listener, thisArg, disposables);
},
onDidRenameFiles: (listener, thisArg, disposables) => {
checkProposedApiEnabled(extension);
return extHostFileSystemEvent.onDidRenameFile(listener, thisArg, disposables);
},
onWillCreateFiles: (listener: (e: vscode.FileWillCreateEvent) => any, thisArg?: any, disposables?: vscode.Disposable[]) => {
checkProposedApiEnabled(extension);
return extHostFileSystemEvent.getOnWillCreateFileEvent(extension)(listener, thisArg, disposables);
},
onWillDeleteFiles: (listener: (e: vscode.FileWillDeleteEvent) => any, thisArg?: any, disposables?: vscode.Disposable[]) => {
checkProposedApiEnabled(extension);
return extHostFileSystemEvent.getOnWillDeleteFileEvent(extension)(listener, thisArg, disposables);
},
onWillRenameFiles: (listener: (e: vscode.FileWillRenameEvent) => any, thisArg?: any, disposables?: vscode.Disposable[]) => {
checkProposedApiEnabled(extension);
return extHostFileSystemEvent.getOnWillRenameFileEvent(extension)(listener, thisArg, disposables);
}
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册