void () { // no need to set myDuringModification - listeners are not added yet CommandProcessor.getInstance().runUndoTransparentAction(() -> { ApplicationManager.getApplication().runWriteAction(() -> { if (myRangeMarker.isValid()) { myDocument2.setReadOnly(false); CharSequence nexText = myRangeMarker.getTextRange().subSequence(myDocument1.getCharsSequence()); myDocument2.setText(nexText); myDocument2.setReadOnly(!myDocument1.isWritable()); } else { myDocument2.setReadOnly(false); try { myDocument2.setText(DiffBundle.message("synchronize.document.and.its.fragment.range.error")); } finally { myDocument2.setReadOnly(true); } } }); }); super.startListen(); }