int delta = gapEnd - oldEnd; int adjIndex = searchFirst(oldEnd); int count = marks.size(); for (int i = adjIndex; i < count; i++) { Mark m = (Mark) marks.get(i); m.mark += delta; }
  protected void shiftEnd(int newSize)  {    assert newSize > (gapEnd - gapStart) : "The new gap size must be greater "                                           + "than the old gap size";    int delta = newSize - gapEnd + gapStart;    // Update the marks after the gapEnd.    adjustPositionsInRange(gapEnd, buffer.length - gapEnd, delta);    // Copy the data around.    char[] newBuf = (char[]) allocateArray(length() + newSize);    System.arraycopy(buffer, 0, newBuf, 0, gapStart);    System.arraycopy(buffer, gapEnd, newBuf, gapStart + newSize, buffer.length        - gapEnd);    gapEnd = gapStart + newSize;    buffer = newBuf;  }