void (int offset, @NotNull CharSequence s) { if (offset < 0) throw new IndexOutOfBoundsException("Wrong offset: " + offset); if (offset > getTextLength()) { throw new IndexOutOfBoundsException("Wrong offset: " + offset + "; documentLength: " + getTextLength()); } assertWriteAccess(); assertValidSeparators(s); if (s.length() == 0) return; RangeMarker marker = getRangeGuard(offset, offset); if (marker != null) { throwGuardedFragment(marker, offset, "", s); } ImmutableCharSequence newText = myText.insert(offset, s); ImmutableCharSequence newString = newText.subtext(offset, offset + s.length()); updateText(newText, offset, "", newString, false, LocalTimeCounter.currentTime(), offset, 0, offset); trimToSize(); }