increate file participant default time to 1 minute, show notification progress which allows for cancellation, https://github.com/microsoft/vscode/issues/111208

This commit is contained in:
Johannes Rieken
2020-11-25 09:26:29 +01:00
parent 00eea33b23
commit 2ea9ecd6da
2 changed files with 16 additions and 6 deletions
@@ -77,7 +77,7 @@ Registry.as<IConfigurationRegistry>(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."),
}
}
@@ -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);
});
}