void (@NotNull Editor editor, @NotNull Caret caret, DataContext dataContext) { Document document = editor.getDocument(); int currentLine = caret.getLogicalPosition().line; boolean atLineStart = caret.getLogicalPosition().column == 0; if (isLineEmpty(document, currentLine) || atLineStart) { while (--currentLine >= 0) { if (!isLineEmpty(document, currentLine)) { break; } } } while (--currentLine >= 0) { if (isLineEmpty(document, currentLine)) { break; } } int targetOffset = 0; if (currentLine >= 0) { int targetLineStart = document.getLineStartOffset(currentLine); int targetLineEnd = document.getLineEndOffset(currentLine); if (targetLineStart == targetLineEnd) { targetOffset = targetLineStart; } else { targetOffset = document.getLineStartOffset(currentLine + 1); } } EditorActionUtil.moveCaret(caret, targetOffset, myWithSelection); }