private static void restoreCaretStateIfNeeded(@NotNull Editor editor, @NotNull SelectionToCopy selectionToCopy) {
    List<CaretState> originalCaretState = selectionToCopy.caretStateToRestore();
    if (originalCaretState != null) {
      Project project = editor.getProject();
      if (project != null) {
        highlightSelections(editor, project);
      }
      editor.getCaretModel().setCaretsAndSelections(originalCaretState);
    }
  }
private static void restoreCaretStateIfNeeded(@NotNull Editor editor, @NotNull SelectionToCopy selectionToCopy)