code: public List<RemoveFromList> repairCommand(final RemoveFromList toRepair, final RemoveFromList repairAgainst) {
          if (toRepair.getStartPosition() + toRepair.getRemoveCount() <= repairAgainst.getStartPosition()) {
              return asList(toRepair);
          }
          if (toRepair.getStartPosition() >= repairAgainst.getStartPosition() + repairAgainst.getRemoveCount()) {
              return asList(createRepaired(toRepair, toRepair.getStartPosition() - repairAgainst.getRemoveCount(),
                      toRepair.getRemoveCount()));
          }
          final int startPosition = toRepair.getStartPosition() < repairAgainst.getStartPosition() ? toRepair
                  .getStartPosition() : repairAgainst.getStartPosition();
  
          final int indicesBefore = repairAgainst.getStartPosition() - toRepair.getStartPosition();
          final int indicesAfter = (toRepair.getStartPosition() + toRepair.getRemoveCount())
                  - (repairAgainst.getStartPosition() + repairAgainst.getRemoveCount());
          final int indicesBeforeAndAfter = max(indicesBefore, 0) + max(indicesAfter, 0);
  
          if (indicesBeforeAndAfter == 0) {
              return asList(createRepaired(toRepair, 0, 0));
          }
  
          final int removeCount = min(indicesBeforeAndAfter, toRepair.getRemoveCount());
          return asList(createRepaired(toRepair, startPosition, removeCount));
      }
docs: Repairs a {@link RemoveFromList} in relation to a {@link RemoveFromList} command.
  
  @param toRepair
  The command to repair.
  @param repairAgainst
  The command to repair against.
  @return The repaired command.