void (@NotNull Editor editor, @NotNull Caret caret, DataContext dataContext) { Runnable runnable = () -> { if (caret.hasSelection() && (!(editor instanceof EditorEx) || !((EditorEx)editor).isStickySelection()) && !Registry.is("editor.action.caretMovement.UpDownIgnoreSelectionBoundaries", false)) { int targetOffset = myDirection == Direction.DOWN ? caret.getSelectionEnd() : caret.getSelectionStart(); caret.moveToOffset(targetOffset); } int lineShift = myDirection == Direction.DOWN ? 1 : -1; caret.moveCaretRelatively(0, lineShift, false, caret == editor.getCaretModel().getPrimaryCaret()); }; EditorUtil.runWithAnimationDisabled(editor, runnable); }