void (final CompletionProgressIndicator indicator, final Runnable laterRunnable) { if (laterRunnable != null) { ActionTracker tracker = new ActionTracker(indicator.getEditor(), indicator); Runnable wrapper = () -> { if (!Disposer.isDisposed(indicator) && !indicator.getProject().isDisposed() && !tracker.hasAnythingHappened()) { laterRunnable.run(); } indicator.disposeIndicator(); }; if (isTestingMode()) { wrapper.run(); } else { ApplicationManager.getApplication().invokeLater(wrapper); } } else { indicator.disposeIndicator(); } }