void (boolean collectChanges) { int currOffs = myEditor.getScrollingModel().getVerticalScrollOffset(); Project project = ProjectUtil.guessCurrentProject(getPanel()); CommandProcessor.getInstance().executeCommand(project, () -> replaceText(project, collectChanges), null, null); myEditor.getSettings().setRightMargin(getAdjustedRightMargin()); myLastDocumentModificationStamp = myEditor.getDocument().getModificationStamp(); myEditor.getScrollingModel().scrollVertically(currOffs); }