void (@NotNull Editor editor, @NotNull Caret caret, DataContext dataContext) { CopyPasteManager.getInstance().stopKillRings(); final Document document = editor.getDocument(); final RangeMarker rangeMarker = document.createRangeMarker(editor.getCaretModel().getOffset(), editor.getCaretModel().getOffset() ); final CharSequence chars = document.getCharsSequence(); int offset = editor.getCaretModel().getOffset(); int lineStart = document.getLineStartOffset(document.getLineNumber(offset)); final CharSequence beforeCaret = chars.subSequence(lineStart, offset); if (CharArrayUtil.containsOnlyWhiteSpaces(beforeCaret)) { String strToInsert = ""; strToInsert += beforeCaret.toString(); strToInsert += "\n"; document.insertString(lineStart, strToInsert); editor.getCaretModel().moveToOffset(offset); } else { DataManager.getInstance().saveInDataContext(dataContext, SPLIT_LINE_KEY, true); try { getEnterHandler().execute(editor, caret, dataContext); } finally { DataManager.getInstance().saveInDataContext(dataContext, SPLIT_LINE_KEY, null); } editor.getCaretModel().moveToOffset(Math.min(document.getTextLength(), rangeMarker.getStartOffset())); editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); } }