void commandFinished(@NlsContexts.Command String commandName, Object groupId, @NotNull CommandMerger nextCommandToMerge) {
    // we do not want to spoil redo stack in situation, when some 'transparent' actions occurred right after undo.
    if (!nextCommandToMerge.isTransparent() && nextCommandToMerge.hasActions()) {
      clearRedoStacks(nextCommandToMerge);
    }

    if (!shouldMerge(groupId, nextCommandToMerge)) {
      flushCurrentCommand();
      myManager.compact(myState);
    }
    merge(nextCommandToMerge);

    if (nextCommandToMerge.isTransparent() || !hasActions()) return;

    if (groupId != SoftReference.dereference(myLastGroupId)) {
      myLastGroupId = groupId == null ? null : new WeakReference<>(groupId);
    }
    if (myCommandName == null) myCommandName = commandName;
  }
void commandFinished(@NlsContexts.Command String commandName, Object groupId, @NotNull CommandMerger nextCommandToMerge)