current.getAttributes(), offset,
next.getAttributes(), offset,
    private void insertContentTag(ElementSpec tag)    {      prepareContentInsertion();      int len = tag.getLength();      int dir = tag.getDirection();      AttributeSet tagAtts = tag.getAttributes();      if (dir == ElementSpec.JoinPreviousDirection)        {          // The mauve tests to this class show that a JoinPrevious insertion          // does not add any edits to the document event. To me this means          // that nothing is done here. The previous element naturally should          // expand so that it covers the new characters.        }      else if (dir == ElementSpec.JoinNextDirection)        {          BranchElement paragraph = (BranchElement) elementStack.peek();          int currentIndex = paragraph.getElementIndex(offset);          Element current = paragraph.getElement(currentIndex);          Element next = paragraph.getElement(currentIndex + 1);          if (next == null)            return;          Element newEl1 = createLeafElement(paragraph,                                             current.getAttributes(),                                             current.getStartOffset(),                                             offset);          Element newEl2 = createLeafElement(paragraph,                                             current.getAttributes(),                                           offset,                                           next.getEndOffset());          Element[] add = new Element[] { newEl1, newEl2 };          Element[] remove = new Element[] { current, next };          paragraph.replace(currentIndex, 2, add);          // Add this action to the document event.          addEdit(paragraph, currentIndex, remove, add);        }      else        {          BranchElement paragraph = (BranchElement) elementStack.peek();          int index = paragraph.getElementIndex(offset);          Element current = paragraph.getElement(index);          Element[] added;          Element[] removed = new Element[] {current};          Element[] splitRes = split(current, offset, length);          if (splitRes[0] == null)            {              added = new Element[2];              added[0] = createLeafElement(paragraph, tagAtts,                                           offset, endOffset);              added[1] = splitRes[1];              removed = new Element[0];              index++;            }          else if (current.getStartOffset() == offset)            {              // This is if the new insertion happens immediately before               // the <code>current</code> Element.  In this case there are 2               // resulting Elements.                            added = new Element[2];              added[0] = createLeafElement(paragraph, tagAtts, offset,                                           endOffset);              added[1] = splitRes[1];            }          else if (current.getEndOffset() == endOffset)            {              // This is if the new insertion happens right at the end of               // the <code>current</code> Element.  In this case there are               // 2 resulting Elements.              added = new Element[2];              added[0] = splitRes[0];              added[1] = createLeafElement(paragraph, tagAtts, offset,                                           endOffset);            }          else            {              // This is if the new insertion is in the middle of the               // <code>current</code> Element.  In this case               // there will be 3 resulting Elements.              added = new Element[3];              added[0] = splitRes[0];              added[1] = createLeafElement(paragraph, tagAtts, offset,                                           endOffset);              added[2] = splitRes[1];            }          paragraph.replace(index, removed.length, added);          addEdit(paragraph, index, removed, added);        }      offset += len;    }