boolean (@NotNull Document document, int offset) { if (offset <= 0 || offset >= document.getTextLength()) return false; CharSequence text = document.getImmutableCharSequence(); char prev = text.charAt(offset - 1); return prev == '\r' ? text.charAt(offset) == '\n' : Character.isHighSurrogate(prev) && Character.isLowSurrogate(text.charAt(offset)); }