44 *--------------------------------------------------------------------------------------------*/
55
66import { mergeSort } from 'vs/base/common/arrays' ;
7- import { dispose , IDisposable , IReference } from 'vs/base/common/lifecycle' ;
7+ import { dispose , IDisposable , IReference , toDisposable } from 'vs/base/common/lifecycle' ;
88import { URI } from 'vs/base/common/uri' ;
99import { ICodeEditor , isCodeEditor } from 'vs/editor/browser/editorBrowser' ;
10- import { IBulkEditOptions , IBulkEditResult , IBulkEditService } from 'vs/editor/browser/services/bulkEditService' ;
10+ import { IBulkEditOptions , IBulkEditResult , IBulkEditService , IBulkEditPreviewHandler } from 'vs/editor/browser/services/bulkEditService' ;
1111import { EditOperation } from 'vs/editor/common/core/editOperation' ;
1212import { Range } from 'vs/editor/common/core/range' ;
1313import { EndOfLineSequence , IIdentifiedSingleEditOperation , ITextModel } from 'vs/editor/common/model' ;
@@ -381,6 +381,8 @@ export class BulkEditService implements IBulkEditService {
381381
382382 _serviceBrand : undefined ;
383383
384+ private _previewHandler ?: IBulkEditPreviewHandler ;
385+
384386 constructor (
385387 @ILogService private readonly _logService : ILogService ,
386388 @IModelService private readonly _modelService : IModelService ,
@@ -393,7 +395,20 @@ export class BulkEditService implements IBulkEditService {
393395 @IConfigurationService private readonly _configurationService : IConfigurationService
394396 ) { }
395397
396- apply ( edit : WorkspaceEdit , options : IBulkEditOptions = { } ) : Promise < IBulkEditResult > {
398+ setPreviewHandler ( handler : IBulkEditPreviewHandler ) : IDisposable {
399+ this . _previewHandler = handler ;
400+ return toDisposable ( ( ) => {
401+ if ( this . _previewHandler === handler ) {
402+ this . _previewHandler = undefined ;
403+ }
404+ } ) ;
405+ }
406+
407+ async apply ( edit : WorkspaceEdit , options : IBulkEditOptions = { } ) : Promise < IBulkEditResult > {
408+
409+ if ( this . _previewHandler ) {
410+ edit = await this . _previewHandler ( edit , options ) ;
411+ }
397412
398413 let { edits } = edit ;
399414 let codeEditor = options . editor ;
0 commit comments