void (final ImplementationViewElement elt) { final String newText = elt.getText(); if (newText == null || Comparing.strEqual(newText, myEditor.getDocument().getText())) return; DocumentUtil.writeInRunUndoTransparentAction(() -> { Document fragmentDoc = myEditor.getDocument(); fragmentDoc.setReadOnly(false); try { fragmentDoc.replaceString(0, fragmentDoc.getTextLength(), newText); } finally { fragmentDoc.setReadOnly(true); } PsiElement element = elt.getElementForShowUsages(); PsiFile file = element == null ? null : element.getContainingFile(); myEditor.getSettings().setTabSize(file != null ? CodeStyle.getIndentOptions(file).TAB_SIZE : CodeStyle.getSettings(elt.getProject()).getTabSize(null)); myEditor.getCaretModel().moveToOffset(0); myEditor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); }); }