void (Editor editor, Project project) { int oldSelectionStart = editor.getSelectionModel().getSelectionStart(); int oldSelectionEnd = editor.getSelectionModel().getSelectionEnd(); if(!editor.getSelectionModel().hasSelection()) { oldSelectionStart = editor.getCaretModel().getOffset(); oldSelectionEnd = oldSelectionStart; } Document document = editor.getDocument(); int startIndex = document.getLineNumber(oldSelectionStart); if(startIndex == -1) { startIndex = document.getLineCount() - 1; } int endIndex = document.getLineNumber(oldSelectionEnd); if(endIndex > 0 && document.getLineStartOffset(endIndex) == oldSelectionEnd && endIndex > startIndex) { endIndex --; } if(endIndex == -1) { endIndex = document.getLineCount() - 1; } if (startIndex < 0 || endIndex < 0) return; int blockIndent = CodeStyle.getIndentOptions(project, document).INDENT_SIZE; IndentSelectionAction.doIndent(endIndex, startIndex, document, project, editor, -blockIndent); }