void (int srcStart, int srcEnd, int dstOffset) { assertBounds(srcStart, srcEnd); if (dstOffset == srcStart || dstOffset == srcEnd) return; ProperTextRange srcRange = new ProperTextRange(srcStart, srcEnd); assert !srcRange.containsOffset(dstOffset) : "Can't perform text move from range [" + srcStart + "; " + srcEnd + ") to offset " + dstOffset; String replacement = getCharsSequence().subSequence(srcStart, srcEnd).toString(); int shift = dstOffset < srcStart ? srcEnd - srcStart : 0; // a pair of insert/remove modifications replaceString(dstOffset, dstOffset, srcStart + shift, replacement, LocalTimeCounter.currentTime(), false); replaceString(srcStart + shift, srcEnd + shift, dstOffset, "", LocalTimeCounter.currentTime(), false); }