void () { ApplicationManager.getApplication().invokeLater(() -> { if (PsiDocumentManagerBase.this.hasEventSystemEnabledUncommittedDocuments()) { // no luck, will try later PsiDocumentManagerBase.this.performLaterWhenAllCommitted(runnable); } else { runnable.run(); } }, modalityState, myProject.getDisposed()); }