}
  protected void shiftGap(int newGapStart)  {    int newGapEnd = newGapStart + (gapEnd - gapStart);    // Update the positions between newGapEnd and (old) gapEnd. The marks    // must be shifted by (gapEnd - newGapEnd).    int index1 = Collections.binarySearch(positions, new GapContentPosition(        gapEnd));    int index2 = Collections.binarySearch(positions, new GapContentPosition(        newGapEnd));    if (index1 > 0 && index2 > 0)    {      int i1 = Math.min(index1, index2);      int i2 = Math.max(index1, index2);      for (ListIterator i = positions.listIterator(i1); i.hasNext();)      {        if (i.nextIndex() > i2)          break;        GapContentPosition p = (GapContentPosition) i.next();        p.mark += gapEnd - newGapEnd;      }    if (newGapStart == gapStart)      return;    else if (newGapStart < gapStart)      {        System.arraycopy(buffer, newGapStart, buffer, newGapEnd, gapStart            - newGapStart);        gapStart = newGapStart;        gapEnd = newGapEnd;      }    else      {        System.arraycopy(buffer, gapEnd, buffer, gapStart, newGapStart            - gapStart);        gapStart = newGapStart;        gapEnd = newGapEnd;      }  }  }