void (@NotNull final Editor editor, @NotNull final MoveInfo info, final boolean down) { final LineRange toMove = info.toMove; final LineRange toMove2 = info.toMove2; if (toMove instanceof MyLineRange && toMove2 instanceof ScopeRange) { PostprocessReformattingAspect.getInstance(editor.getProject()).disablePostprocessFormattingInside(() -> { final PsiElement startToMove = ((MyLineRange)toMove).myStartElement; final PsiElement endToMove = ((MyLineRange)toMove).myEndElement; final PsiFile file = startToMove.getContainingFile(); final SelectionModel selectionModel = editor.getSelectionModel(); final CaretModel caretModel = editor.getCaretModel(); final int selectionStart = selectionModel.getSelectionStart(); final LogicalPosition selectionBeforeMoveStart = editor.offsetToLogicalPosition(selectionStart); final LogicalPosition selectionBeforeMoveEnd = editor.offsetToLogicalPosition(selectionModel.getSelectionEnd()); boolean isSelectionStartAtCaret = caretModel.getOffset() == selectionStart; final SelectionContainer selectionLen = getSelectionLenContainer(editor, ((MyLineRange)toMove)); int shift = getCaretShift(startToMove, endToMove, caretModel, isSelectionStartAtCaret); final boolean hasSelection = selectionModel.hasSelection(); int offset; if (((ScopeRange)toMove2).isTheSameLevel()) { offset = moveTheSameLevel((ScopeRange)toMove2, (MyLineRange)toMove); } else { offset = moveInOut(((MyLineRange)toMove), editor, info); } final LogicalPosition positionOffsetAfterMove = editor.offsetToLogicalPosition(offset); restoreCaretAndSelection(file, editor, isSelectionStartAtCaret, hasSelection, selectionLen, shift, offset, (MyLineRange)toMove, selectionBeforeMoveStart, selectionBeforeMoveEnd, positionOffsetAfterMove); info.toMove2 = info.toMove; //do not move further }); } }