public static void copyToClipboard(@NotNull Editor editor,
                                     @NotNull TransferableProvider transferableProvider,
                                     @NotNull SelectionToCopy selectionToCopy) {
    Transferable transferable = transferableProvider.getSelection(editor, selectionToCopy.copyPasteOptions());
    if (transferable != null) {
      CopyPasteManager.getInstance().setContents(transferable);

      if (editor instanceof EditorEx ex) {
        if (ex.isStickySelection()) {
          ex.setStickySelection(false);
        }
      }
    }
    restoreCaretStateIfNeeded(editor, selectionToCopy);
  }
public static void copyToClipboard(@NotNull Editor editor,
                                     @NotNull TransferableProvider transferableProvider,
                                     @NotNull SelectionToCopy selectionToCopy)