fun handleEnterAddBiggerIndentFromBelow()

in rider-fsharp/src/main/java/com/jetbrains/rider/plugins/fsharp/editorActions/FSharpEnterHandlerDelegate.kt [674:706]


  fun handleEnterAddBiggerIndentFromBelow(editor: Editor, caretOffset: Int): Boolean {
    val document = editor.document
    val caretCoords = document.offsetToDocCoordinates(caretOffset)
    val caretLine = caretCoords.line

    if (caretLine + 1 >= document.lineCount) return false

    val lineStartOffset = document.getLineStartOffset(caretLine)
    val iterator = editor.highlighter.createIterator(lineStartOffset)
    var seenComment = false

    if (iterator.atEnd()) return false

    while (!iterator.atEnd() && (
        iterator.tokenType == FSharpTokenType.WHITESPACE ||
          (iterator.tokenType != null && iterator.tokenType.isComment && iterator.start < caretOffset)
        )
    ) {
      seenComment = seenComment || iterator.tokenType.isComment
      iterator.advance()
    }

    if (iterator.tokenTypeSafe != FSharpTokenType.NEW_LINE) return false

    val currentIndent = if (seenComment) 0 else caretCoords.column

    val nestedIndentBelow = tryGetNestedIndentBelow(editor, caretLine, seenComment, currentIndent)
    if (nestedIndentBelow == null) return false

    val (_, lineIndent) = nestedIndentBelow
    insertNewLineAt(editor, lineIndent.indent, caretOffset, false)
    return true
  }