src/vs/workbench/contrib/bulkEdit/browser/bulkTextEdits.ts/BulkTextEdits/apply
class BulkTextEdits:	async apply(): Promise<void> {

		this._validateBeforePrepare();
		const tasks = await this._createEditsTasks();

		if (this._token.isCancellationRequested) {
			return;
		}
		try {

			const validation = this._validateTasks(tasks);
			if (!validation.canApply) {
				throw new Error(`${validation.reason.toString()} has changed in the meantime`);
			}
			if (tasks.length === 1) {
				// This edit touches a single model => keep things simple
				const task = tasks[0];
				if (!task.isNoOp()) {
					const singleModelEditStackElement = new SingleModelEditStackElement(task.model, task.getBeforeCursorState());
					this._undoRedoService.pushElement(singleModelEditStackElement, this._undoRedoGroup, this._undoRedoSource);
					task.apply();
					singleModelEditStackElement.close();
				}
				this._progress.report(undefined);
			} else {
				// prepare multi model undo element
				const multiModelEditStackElement = new MultiModelEditStackElement(
					this._label,
					tasks.map(t => new SingleModelEditStackElement(t.model, t.getBeforeCursorState()))
				);
				this._undoRedoService.pushElement(multiModelEditStackElement, this._undoRedoGroup, this._undoRedoSource);
				for (const task of tasks) {
					task.apply();
					this._progress.report(undefined);
				}
				multiModelEditStackElement.close();
			}

		} finally {
			dispose(tasks);
		}
	}