@Override
  public void addOuterRange(@NotNull TextRange newRange, boolean isInsertion) {
    if (newRange.isEmpty()) {
      return;
    }
    assertRangeOrder(newRange);

    if (!myOuterAndRemoveRanges.isEmpty()) {
      int lastItemIndex = myOuterAndRemoveRanges.size() - 1;
      TextRange lastRange = myOuterAndRemoveRanges.get(lastItemIndex);
      if (lastRange.getEndOffset() == newRange.getStartOffset() && !(lastRange instanceof RangeToRemove)) {
        TextRange joinedRange =
          lastRange instanceof InsertionRange || isInsertion
          ? new InsertionRange(lastRange.getStartOffset(), newRange.getEndOffset())
          : TextRange.create(lastRange.getStartOffset(), newRange.getEndOffset());
        myOuterAndRemoveRanges.set(lastItemIndex, joinedRange);
        return;
      }
    }
    myOuterAndRemoveRanges.add(isInsertion ? new InsertionRange(newRange.getStartOffset(), newRange.getEndOffset()) : newRange);
  }
@Override
  public void addOuterRange(@NotNull TextRange newRange, boolean isInsertion)