void () { myBlocksToModify = collectBlocksToModify(); // call doModifications static method to ensure no access to state // thus we may clear formatting state //reset(); //myDisposed = true; if (myBlocksToModify.isEmpty()) { setDone(true); return; } myProgressCallback.beforeApplyingFormatChanges(myBlocksToModify); final int blocksToModifyCount = myBlocksToModify.size(); if (blocksToModifyCount > BULK_REPLACE_OPTIMIZATION_CRITERIA) { applyChangesAtRewriteMode(myBlocksToModify, myModel); setDone(true); } else if (blocksToModifyCount > 50) { DocumentEx updatedDocument = getAffectedDocument(myModel); if (updatedDocument != null) { updatedDocument.setInBulkUpdate(true); myResetBulkUpdateState = true; } } }