@ApiStatus.Internal
  public static String getSelectedTextForClipboard(@NotNull Editor editor, @NotNull CopyPasteOptions options,
                                                   @NotNull Collection<? super TextBlockTransferableData> extraDataCollector) {
    final StringBuilder buf = new StringBuilder();
    String separator = "";
    List<Caret> carets = editor.getCaretModel().getAllCarets();
    int[] startOffsets = new int[carets.size()];
    int[] endOffsets = new int[carets.size()];
    for (int i = 0; i < carets.size(); i++) {
      buf.append(separator);
      String caretSelectedText = StringUtil.notNullize(carets.get(i).getSelectedText());
      startOffsets[i] = buf.length();
      buf.append(caretSelectedText);
      if (options.isCopiedFromEmptySelection() && !caretSelectedText.endsWith("\n")) {
        buf.append("\n");  // make sure the last line with no '\n' is still copied as a real line
      }
      endOffsets[i] = buf.length();
      separator = "\n";
    }
    extraDataCollector.add(new CaretStateTransferableData(startOffsets, endOffsets));

    // IDEA-313776 Can not paste the text (data) on the windows remote desktop, copied from IDEA editor
    // For some reason, copy-pasting doesn't work from host Windows to an older remote Windows connected through RDP
    // (like Window Server 2012, or 2008) in case there's transferable data implementing Serializable.
    // As a workaround, we only put that data if the corresponding advanced setting is enabled.
    if (getCopiedFromEmptySelectionPasteMode() != AT_CARET) {
      extraDataCollector.add(new CopyPasteOptionsTransferableData(options));
    }

    return buf.toString();
  }
@ApiStatus.Internal
  public static String getSelectedTextForClipboard(@NotNull Editor editor, @NotNull CopyPasteOptions options,
                                                   @NotNull Collection<? super TextBlockTransferableData> extraDataCollector)