boolean splitGlobalCommand(@NotNull UndoRedo undoRedo) {
    UndoableGroup group = undoRedo.myUndoableGroup;
    Collection<DocumentReference> refs = undoRedo.getDocRefs();
    if (refs == null || refs.size() != 1) return false;
    DocumentReference docRef = refs.iterator().next();

    ClientState clientState = getClientState(undoRedo.myEditor);
    if (clientState == null) return false;
    UndoRedoStacksHolder stackHolder = getStackHolder(clientState, true);

    UndoRedoList<UndoableGroup> stack = stackHolder.getStack(docRef);
    if (stack.getLast() == group) {
      Pair<List<UndoableAction>, List<UndoableAction>> actions = separateLocalAndNonLocalActions(group.getActions(), docRef);
      if (actions.first.isEmpty()) return false;

      stack.removeLast();

      UndoableGroup replacingGroup = new UndoableGroup(IdeBundle.message("undo.command.local.name") + group.getCommandName(),
                                                       false,
                                                       group.getCommandTimestamp(),
                                                       group.getStateBefore(),
                                                       group.getStateAfter(),
                                                       // only action that changes file locally
                                                       actions.first,
                                                       stackHolder, getProject(), group.getConfirmationPolicy(), group.isTransparent(),
                                                       group.isValid());
      stack.add(replacingGroup);

      UndoableGroup groupWithoutLocalChanges = new UndoableGroup(group.getCommandName(),
                                                                 group.isGlobal(),
                                                                 group.getCommandTimestamp(),
                                                                 group.getStateBefore(),
                                                                 group.getStateAfter(),
                                                                 // all action except local
                                                                 actions.second,
                                                                 stackHolder, getProject(), group.getConfirmationPolicy(), group.isTransparent(),
                                                                 group.isValid());

      if (stackHolder.replaceOnStacks(group, groupWithoutLocalChanges)) {
        replacingGroup.setOriginalContext(new UndoableGroup.UndoableGroupOriginalContext(group, groupWithoutLocalChanges));
      }

      return true;
    }

    return false;
  }
boolean splitGlobalCommand(@NotNull UndoRedo undoRedo)