private static @Nullable SelectionToCopy prepareSelectionToCopy(@NotNull Editor editor,
                                                                  boolean isToMoveCaretToSelectionStart,
                                                                  boolean isToPreserveOriginalCaretState) {
    if (editor.getSelectionModel().hasSelection(true)) {
      return new SelectionToCopy(CopyPasteOptions.DEFAULT, null);
    }
    if (isSkipCopyPasteForEmptySelection()) {
      return null;
    }

    CaretModel caretModel = editor.getCaretModel();

    List<CaretState> originalCaretState = isToPreserveOriginalCaretState ? caretModel.getCaretsAndSelections() : null;
    caretModel.runForEachCaret(caret -> {
      EditorActionUtil.selectEntireLines(caret);
      if (isToMoveCaretToSelectionStart && caret.hasSelection()) {
        caret.moveToVisualPosition(caret.getSelectionStartPosition());
      }
    });
    CopyPasteOptions copyPasteOptions = new CopyPasteOptions(true);
    return new SelectionToCopy(copyPasteOptions, originalCaretState);
  }
private static @Nullable SelectionToCopy prepareSelectionToCopy(@NotNull Editor editor,
                                                                  boolean isToMoveCaretToSelectionStart,
                                                                  boolean isToPreserveOriginalCaretState)