boolean (@NotNull CharSequence text, @NotNull InlineChunk word1, @NotNull InlineChunk word2) { if (word1 instanceof NewlineChunk || word2 instanceof NewlineChunk) return true; int offset1 = word1.getOffset2(); int offset2 = word2.getOffset1(); for (int i = offset1; i < offset2; i++) { if (isWhiteSpace(text.charAt(i))) return true; } return false; }