text: public void seek(int index) {if (index == currentCharIndex) {return;}if (index > currentCharIndex) {sync(index - currentCharIndex);index = Math.min(index, getBufferStartIndex() + n - 1);}int i = index - getBufferStartIndex();if ( i < 0 ) {throw new IllegalArgumentException("cannot seek to negative index " + index);}else if (i >= n) {throw new UnsupportedOperationException("seek to index outside buffer: "+index+" not in "+getBufferStartIndex()+".."+(getBufferStartIndex()+n));}p = i;currentCharIndex = index;if (p == 0) {lastChar = lastCharBufferStart;}else {lastChar = data[p-1];}}