String (Project project, PsiFile file, Editor editor, String text, RawText rawText) { if (!file.getViewProvider().hasLanguage(YAMLLanguage.INSTANCE)) return text; CaretModel caretModel = editor.getCaretModel(); SelectionModel selectionModel = editor.getSelectionModel(); int caretOffset = selectionModel.getSelectionStart() != selectionModel.getSelectionEnd() ? selectionModel.getSelectionStart() : caretModel.getOffset(); if (isCommentElement(file.findElementAt(caretOffset))) return text; Document document = editor.getDocument(); int lineNumber = document.getLineNumber(caretOffset); int lineStartOffset = YAMLTextUtil.getLineStartSafeOffset(document, lineNumber); int indent = caretOffset - lineStartOffset; boolean smartPaste = YAMLEditorOptions.getInstance().isUseSmartPaste(); String specialKeyPaste = smartPaste ? tryToPasteAsKeySequence(text, file, editor, caretOffset, indent) : null; if (specialKeyPaste != null) { return specialKeyPaste; } if (indent == 0 || !canBeInsertedWithIndentAdjusted(file, caretOffset)) { // It could be copy and paste of lines // User could fix indentation later if he wanted to copy some block into top-level block return text; } return indentText(text, StringUtil.repeatSymbol(' ', indent), shouldInsertIndentAtTheEnd(caretOffset, document)); }