From 2ea9ecd6da760369af5259e0fac29124316830de Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Wed, 25 Nov 2020 09:23:49 +0100 Subject: [PATCH] increate file participant default time to 1 minute, show notification progress which allows for cancellation, https://github.com/microsoft/vscode/issues/111208 --- .../mainThreadFileSystemEventService.ts | 2 +- .../workingCopyFileOperationParticipant.ts | 20 ++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/vs/workbench/api/browser/mainThreadFileSystemEventService.ts b/src/vs/workbench/api/browser/mainThreadFileSystemEventService.ts index b6e0a210a30..81905c6b1d0 100644 --- a/src/vs/workbench/api/browser/mainThreadFileSystemEventService.ts +++ b/src/vs/workbench/api/browser/mainThreadFileSystemEventService.ts @@ -77,7 +77,7 @@ Registry.as(Extensions.Configuration).registerConfigurat properties: { 'files.participants.timeout': { type: 'number', - default: 5000, + default: 60000, markdownDescription: localize('files.participants.timeout', "Timeout in milliseconds after which file participants for create, rename, and delete are cancelled. Use `0` to disable participants."), } } diff --git a/src/vs/workbench/services/workingCopy/common/workingCopyFileOperationParticipant.ts b/src/vs/workbench/services/workingCopy/common/workingCopyFileOperationParticipant.ts index d7723c151a4..185f3546b45 100644 --- a/src/vs/workbench/services/workingCopy/common/workingCopyFileOperationParticipant.ts +++ b/src/vs/workbench/services/workingCopy/common/workingCopyFileOperationParticipant.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { localize } from 'vs/nls'; -import { raceTimeout } from 'vs/base/common/async'; +import { raceCancellation } from 'vs/base/common/async'; import { CancellationTokenSource } from 'vs/base/common/cancellation'; import { ILogService } from 'vs/platform/log/common/log'; import { IProgressService, ProgressLocation } from 'vs/platform/progress/common/progress'; @@ -40,10 +40,13 @@ export class WorkingCopyFileOperationParticipant extends Disposable { } const cts = new CancellationTokenSource(); + const timer = setTimeout(() => cts.cancel(), timeout); return this.progressService.withProgress({ - location: ProgressLocation.Window, - title: this.progressLabel(operation) + location: ProgressLocation.Notification, + title: this.progressLabel(operation), + cancellable: true, + delay: Math.min(timeout / 2, 3000) }, async progress => { // For each participant @@ -51,14 +54,21 @@ export class WorkingCopyFileOperationParticipant extends Disposable { if (cts.token.isCancellationRequested) { break; } - try { const promise = participant.participate(files, operation, undoRedoGroupId, isUndoing, progress, timeout, cts.token); - await raceTimeout(promise, timeout, () => cts.dispose(true /* cancel */)); + await raceCancellation(promise, cts.token); } catch (err) { this.logService.warn(err); } } + }, () => { + // user cancel + cts.cancel(); + + }).finally(() => { + // cleanup + cts.dispose(); + clearTimeout(timer); }); } -- GitLab