public static void copyToKillRing(final @NotNull Editor editor, int startOffset, int endOffset, boolean cut) {
    Document document = editor.getDocument();
    String s = document.getCharsSequence().subSequence(startOffset, endOffset).toString();
    s = StringUtil.convertLineSeparators(s);
    CopyPasteManager.getInstance().setContents(new KillRingTransferable(s, document, startOffset, endOffset, cut));
    if (editor instanceof EditorEx ex) {
      if (ex.isStickySelection()) {
        ex.setStickySelection(false);
      }
    }
  }
public static void copyToKillRing(final @NotNull Editor editor, int startOffset, int endOffset, boolean cut)