private int adjustBackward(int pos) {
      if (pos <= offset) return pos;
      if (pos <= offset + newLength) return offset;
      return pos - newLength + oldLength;
    }
private int adjustBackward(int pos)