void () { int originalSelectionStart = Math.min(myStartSessionSelectionMarker.getStartOffset(), myEditor.getDocument().getTextLength()); int originalSelectionEnd = Math.min(myStartSessionSelectionMarker.getEndOffset(), myEditor.getDocument().getTextLength()); try { if (myFindModel.isGlobal()) { mySelectionUpdatedFromSearchResults = true; } myEditor.getSelectionModel().setSelection(originalSelectionStart, originalSelectionEnd); } finally { mySelectionUpdatedFromSearchResults = false; } myEditor.getCaretModel().moveToOffset(Math.min(myStartSessionCaretMarker.getEndOffset(), myEditor.getDocument().getTextLength())); myEditor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); logSelectionUpdate(); }