diff --git a/src/vs/workbench/contrib/bulkEdit/browser/bulkEditService.ts b/src/vs/workbench/contrib/bulkEdit/browser/bulkEditService.ts index a4ba533e180c0b..b982296acd38fd 100644 --- a/src/vs/workbench/contrib/bulkEdit/browser/bulkEditService.ts +++ b/src/vs/workbench/contrib/bulkEdit/browser/bulkEditService.ts @@ -18,7 +18,7 @@ import { Extensions, IConfigurationRegistry } from '../../../../platform/configu import { IDialogService } from '../../../../platform/dialogs/common/dialogs.js'; import { InstantiationType, registerSingleton } from '../../../../platform/instantiation/common/extensions.js'; import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js'; -import { ILogService } from '../../../../platform/log/common/log.js'; +import { canLog, ILogService, LogLevel } from '../../../../platform/log/common/log.js'; import { IProgress, IProgressStep, Progress } from '../../../../platform/progress/common/progress.js'; import { Registry } from '../../../../platform/registry/common/platform.js'; import { UndoRedoGroup, UndoRedoSource } from '../../../../platform/undoRedo/common/undoRedo.js'; @@ -141,26 +141,33 @@ class BulkEdit { return resources.flat(); } + private _logEdits(operation: string, edits: ResourceEdit[]): void { + // avoid serializing (potentially very many) edits when debug logging is off + if (canLog(this._logService.getLevel(), LogLevel.Debug)) { + this._logService.debug(operation, JSON.stringify(edits)); + } + } + private async _performFileEdits(edits: ResourceFileEdit[], undoRedoGroup: UndoRedoGroup, undoRedoSource: UndoRedoSource | undefined, confirmBeforeUndo: boolean, progress: IProgress): Promise { - this._logService.debug('_performFileEdits', JSON.stringify(edits)); + this._logEdits('_performFileEdits', edits); const model = this._instaService.createInstance(BulkFileEdits, this._label || localize('workspaceEdit', "Workspace Edit"), this._code || 'undoredo.workspaceEdit', undoRedoGroup, undoRedoSource, confirmBeforeUndo, progress, this._token, edits); return await model.apply(); } private async _performTextEdits(edits: ResourceTextEdit[], undoRedoGroup: UndoRedoGroup, undoRedoSource: UndoRedoSource | undefined, progress: IProgress, reason: TextModelEditSource | undefined): Promise { - this._logService.debug('_performTextEdits', JSON.stringify(edits)); + this._logEdits('_performTextEdits', edits); const model = this._instaService.createInstance(BulkTextEdits, this._label || localize('workspaceEdit', "Workspace Edit"), this._code || 'undoredo.workspaceEdit', this._editor, undoRedoGroup, undoRedoSource, progress, this._token, edits); return await model.apply(reason); } private async _performCellEdits(edits: ResourceNotebookCellEdit[], undoRedoGroup: UndoRedoGroup, undoRedoSource: UndoRedoSource | undefined, progress: IProgress): Promise { - this._logService.debug('_performCellEdits', JSON.stringify(edits)); + this._logEdits('_performCellEdits', edits); const model = this._instaService.createInstance(BulkCellEdits, undoRedoGroup, undoRedoSource, progress, this._token, edits); return await model.apply(); } private async _performOpaqueEdits(edits: ResourceAttachmentEdit[], undoRedoGroup: UndoRedoGroup, undoRedoSource: UndoRedoSource | undefined, progress: IProgress): Promise { - this._logService.debug('_performOpaqueEdits', JSON.stringify(edits)); + this._logEdits('_performOpaqueEdits', edits); const model = this._instaService.createInstance(OpaqueEdits, undoRedoGroup, undoRedoSource, progress, this._token, edits); return await model.apply(); }