mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-09 08:15:05 +01:00
expose CancellationToken on onWill-file events
This commit is contained in:
@@ -600,14 +600,17 @@ export class Emitter<T> {
|
||||
|
||||
|
||||
export interface IWaitUntil {
|
||||
token: CancellationToken;
|
||||
waitUntil(thenable: Promise<unknown>): void;
|
||||
}
|
||||
|
||||
export type IWaitUntilData<T> = Omit<Omit<T, 'waitUntil'>, 'token'>;
|
||||
|
||||
export class AsyncEmitter<T extends IWaitUntil> extends Emitter<T> {
|
||||
|
||||
private _asyncDeliveryQueue?: LinkedList<[Listener<T>, Omit<T, 'waitUntil'>]>;
|
||||
private _asyncDeliveryQueue?: LinkedList<[Listener<T>, IWaitUntilData<T>]>;
|
||||
|
||||
async fireAsync(data: Omit<T, 'waitUntil'>, token: CancellationToken, promiseJoin?: (p: Promise<unknown>, listener: Function) => Promise<unknown>): Promise<void> {
|
||||
async fireAsync(data: IWaitUntilData<T>, token: CancellationToken, promiseJoin?: (p: Promise<unknown>, listener: Function) => Promise<unknown>): Promise<void> {
|
||||
if (!this._listeners) {
|
||||
return;
|
||||
}
|
||||
@@ -627,6 +630,7 @@ export class AsyncEmitter<T extends IWaitUntil> extends Emitter<T> {
|
||||
|
||||
const event = <T>{
|
||||
...data,
|
||||
token,
|
||||
waitUntil: (p: Promise<unknown>): void => {
|
||||
if (Object.isFrozen(thenables)) {
|
||||
throw new Error('waitUntil can NOT be called asynchronous');
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Emitter, Event, AsyncEmitter, IWaitUntil } from 'vs/base/common/event';
|
||||
import { Emitter, Event, AsyncEmitter, IWaitUntil, IWaitUntilData } from 'vs/base/common/event';
|
||||
import { IRelativePattern, parse } from 'vs/base/common/glob';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/common/extHostDocumentsAndEditors';
|
||||
@@ -189,7 +189,7 @@ export class ExtHostFileSystemEventService implements ExtHostFileSystemEventServ
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private async _fireWillEvent<E extends IWaitUntil>(emitter: AsyncEmitter<E>, data: Omit<E, 'waitUntil'>, timeout: number, token: CancellationToken): Promise<IWillRunFileOperationParticipation | undefined> {
|
||||
private async _fireWillEvent<E extends IWaitUntil>(emitter: AsyncEmitter<E>, data: IWaitUntilData<E>, timeout: number, token: CancellationToken): Promise<IWillRunFileOperationParticipation | undefined> {
|
||||
|
||||
const extensionNames = new Set<string>();
|
||||
const edits: WorkspaceEdit[] = [];
|
||||
|
||||
Vendored
+15
@@ -10554,6 +10554,11 @@ declare module 'vscode' {
|
||||
*/
|
||||
export interface FileWillCreateEvent {
|
||||
|
||||
/**
|
||||
* A cancellation token.
|
||||
*/
|
||||
readonly token: CancellationToken;
|
||||
|
||||
/**
|
||||
* The files that are going to be created.
|
||||
*/
|
||||
@@ -10609,6 +10614,11 @@ declare module 'vscode' {
|
||||
*/
|
||||
export interface FileWillDeleteEvent {
|
||||
|
||||
/**
|
||||
* A cancellation token.
|
||||
*/
|
||||
readonly token: CancellationToken;
|
||||
|
||||
/**
|
||||
* The files that are going to be deleted.
|
||||
*/
|
||||
@@ -10664,6 +10674,11 @@ declare module 'vscode' {
|
||||
*/
|
||||
export interface FileWillRenameEvent {
|
||||
|
||||
/**
|
||||
* A cancellation token.
|
||||
*/
|
||||
readonly token: CancellationToken;
|
||||
|
||||
/**
|
||||
* The files that are going to be renamed.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user