From e40111cc076c2e0e47303c9e7104c0b610c64651 Mon Sep 17 00:00:00 2001 From: Logan Ramos Date: Thu, 16 May 2024 07:48:05 -0700 Subject: [PATCH] Part of #211878 --- .../contrib/files/browser/explorerService.ts | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/vs/workbench/contrib/files/browser/explorerService.ts b/src/vs/workbench/contrib/files/browser/explorerService.ts index dd44d65f5e87b..1c67fc0f491a0 100644 --- a/src/vs/workbench/contrib/files/browser/explorerService.ts +++ b/src/vs/workbench/contrib/files/browser/explorerService.ts @@ -19,7 +19,7 @@ import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity' import { IBulkEditService, ResourceFileEdit } from 'vs/editor/browser/services/bulkEditService'; import { UndoRedoSource } from 'vs/platform/undoRedo/common/undoRedo'; import { IExplorerView, IExplorerService } from 'vs/workbench/contrib/files/browser/files'; -import { IProgressService, ProgressLocation, IProgressNotificationOptions, IProgressCompositeOptions } from 'vs/platform/progress/common/progress'; +import { IProgressService, ProgressLocation, IProgressCompositeOptions, IProgressOptions } from 'vs/platform/progress/common/progress'; import { CancellationTokenSource } from 'vs/base/common/cancellation'; import { RunOnceScheduler } from 'vs/base/common/async'; import { IHostService } from 'vs/workbench/services/host/browser/host'; @@ -184,12 +184,23 @@ export class ExplorerService implements IExplorerService { async applyBulkEdit(edit: ResourceFileEdit[], options: { undoLabel: string; progressLabel: string; confirmBeforeUndo?: boolean; progressLocation?: ProgressLocation.Explorer | ProgressLocation.Window }): Promise { const cancellationTokenSource = new CancellationTokenSource(); - const promise = this.progressService.withProgress({ - location: options.progressLocation || ProgressLocation.Window, - title: options.progressLabel, - cancellable: edit.length > 1, // Only allow cancellation when there is more than one edit. Since cancelling will not actually stop the current edit that is in progress. - delay: 500, - }, async progress => { + const location = options.progressLocation ?? ProgressLocation.Window; + let progressOptions; + if (location === ProgressLocation.Window) { + progressOptions = { + location: location, + title: options.progressLabel, + cancellable: edit.length > 1, + } satisfies IProgressOptions; + } else { + progressOptions = { + location: location, + title: options.progressLabel, + cancellable: edit.length > 1, + delay: 500, + } satisfies IProgressCompositeOptions; + } + const promise = this.progressService.withProgress(progressOptions, async progress => { await this.bulkEditService.apply(edit, { undoRedoSource: UNDO_REDO_SOURCE, label: options.undoLabel,