fun findNonEmptyLineWithSameConstraints()

in src/commonMain/kotlin/org/intellij/markdown/parser/markerblocks/MarkdownParserUtil.kt [72:94]


    fun findNonEmptyLineWithSameConstraints(constraints: MarkdownConstraints,
                                            pos: LookaheadText.Position): LookaheadText.Position? {
        var currentPos = pos

        while (true) {
//            currentPos = currentPos.nextLinePosition() ?: return null

            val nextLineConstraints = constraints.applyToNextLineAndAddModifiers(currentPos)
            // kinda equals
            if (!(nextLineConstraints.upstreamWith(constraints) && nextLineConstraints.extendsPrev(constraints))) {
                return null
            }

            val stringAfterConstraints = nextLineConstraints.eatItselfFromString(currentPos.currentLine)

            if (!MarkdownParserUtil.isEmptyOrSpaces(stringAfterConstraints)) {
                return currentPos
            } else {
                currentPos = currentPos.nextLinePosition()
                        ?: return null
            }
        }
    }