private static LineAdjustmentMode adjustmentAfterInsertion(PsiFile file, int caretOffset) {
    PsiElement element = file.findElementAt(caretOffset);

    if (element != null) {
      if (PsiUtilCore.getElementType(element) == YAMLTokenTypes.SCALAR_LIST ||
          PsiUtilCore.getElementType(element.getParent()) == YAMLElementTypes.SCALAR_LIST_VALUE) {
        return LineAdjustmentMode.None;
      }
      TokenSet ends = TokenSet.create(YAMLTokenTypes.EOL, YAMLTokenTypes.SCALAR_EOL, YAMLTokenTypes.COMMENT);
      IElementType nextType = PsiUtilCore.getElementType(element.getNextSibling());
      if (PsiUtilCore.getElementType(element) == YAMLTokenTypes.INDENT && (nextType == null || ends.contains(nextType))) {
        return LineAdjustmentMode.Indent;
      }
    }

    PsiElement previousElement;
    if (element == null) {
      if (caretOffset > 0) {
        previousElement = file.findElementAt(caretOffset - 1);
      }
      else {
        return LineAdjustmentMode.Indent;
      }
    }
    else {
      previousElement = PsiTreeUtil.prevLeaf(element, true);
    }
    if (PsiUtilCore.getElementType(previousElement) == TokenType.WHITE_SPACE) previousElement = PsiTreeUtil.prevLeaf(previousElement, true);

    if (PsiUtilCore.getElementType(previousElement) == YAMLTokenTypes.INDENT ||
        PsiUtilCore.getElementType(previousElement) == YAMLTokenTypes.EOL) {
      return LineAdjustmentMode.Indent;
    }

    if (PsiUtilCore.getElementType(previousElement) == YAMLTokenTypes.SEQUENCE_MARKER ||
        PsiUtilCore.getElementType(previousElement) == YAMLTokenTypes.TEXT && previousElement.textMatches("-")) {
      return LineAdjustmentMode.ListItem;
    }

    return LineAdjustmentMode.None;
  }
private static LineAdjustmentMode adjustmentAfterInsertion(PsiFile file, int caretOffset)