void (@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { Document document = editor.getDocument(); int startOffset; int endOffset; boolean hasSelection = editor.getSelectionModel().hasSelection(); if (hasSelection){ startOffset = editor.getSelectionModel().getSelectionStart(); endOffset = editor.getSelectionModel().getSelectionEnd() - 1; } else{ startOffset = endOffset = editor.getCaretModel().getOffset(); } int line1 = editor.offsetToLogicalPosition(startOffset).line; int col = editor.getCaretModel().getLogicalPosition().column; try{ adjustLineIndent(file, document, startOffset, endOffset, line1, project); } catch(IncorrectOperationException e){ LOG.error(e); } if (!hasSelection){ if (line1 < document.getLineCount() - 1){ if (document.getLineStartOffset(line1 + 1) + col >= document.getTextLength()) { col = document.getLineEndOffset(line1 + 1) - document.getLineStartOffset(line1 + 1); } LogicalPosition pos = new LogicalPosition(line1 + 1, col); editor.getCaretModel().moveToLogicalPosition(pos); editor.getSelectionModel().removeSelection(); editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); } } }