void runBatchFoldingOperation(@NotNull Runnable operation,
                                boolean dontCollapseCaret,
                                boolean moveCaret,
                                boolean adjustScrollingPosition) {
    assertIsDispatchThreadForEditor();
    if (myEditor.getInlayModel().isInBatchMode()) LOG.error("Folding operations shouldn't be performed during inlay batch update");

    boolean oldDontCollapseCaret = myDoNotCollapseCaret;
    myDoNotCollapseCaret |= dontCollapseCaret;
    boolean oldBatchFlag = myIsBatchFoldingProcessing;
    if (!oldBatchFlag && adjustScrollingPosition) {
      ((ScrollingModelImpl)myEditor.getScrollingModel()).finishAnimation();
      myScrollingPositionKeeper.savePosition();
    }

    myIsBatchFoldingProcessing = true;
    try {
      operation.run();
    }
    finally {
      if (!oldBatchFlag) {
        myIsBatchFoldingProcessing = false;
        if (myFoldRegionsProcessed) {
          onFoldProcessingEnd(moveCaret, adjustScrollingPosition);
        }
        else {
          update(myRegionWidthChanged, myRegionHeightChanged, myGutterRendererChanged, myRepaintRequested);
        }
        myFoldRegionsProcessed = false;
        myRegionWidthChanged = false;
        myRegionHeightChanged = false;
        myGutterRendererChanged = false;
        myRepaintRequested = false;
      }
      myDoNotCollapseCaret = oldDontCollapseCaret;
    }
  }
void runBatchFoldingOperation(@NotNull Runnable operation,
                                boolean dontCollapseCaret,
                                boolean moveCaret,
                                boolean adjustScrollingPosition)