void () { final XDebuggerEditorBase inputEditor = getInputEditor(); int offset = -1; //try to save caret position Editor editor = inputEditor.getEditor(); if (editor != null) { offset = editor.getCaretModel().getOffset(); } final XDebuggerTree tree = myTreePanel.getTree(); tree.markNodesObsolete(); tree.setRoot(new EvaluatingExpressionRootNode(this, tree), false); tree.selectNodeOnLoad(XDebuggerEvaluationDialog::isFirstChild, Conditions.alwaysFalse()); myResultPanel.invalidate(); //editor is already changed editor = inputEditor.getEditor(); inputEditor.requestFocusInEditor(); //try to restore caret position and clear selection if (offset >= 0 && editor != null) { offset = Math.min(editor.getDocument().getTextLength(), offset); editor.getCaretModel().moveToOffset(offset); editor.getSelectionModel().setSelection(offset, offset); } }