void (Editor editor, Caret caret) { if (caret.hasSelection()) { caret.moveToOffset(caret.getSelectionEnd()); } else if (myCaretRestoreOffset != CANNOT_JOIN) { caret.moveToOffset(myCaretRestoreOffset); if (caret == editor.getCaretModel().getPrimaryCaret()) { // performance editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); } caret.removeSelection(); } }