boolean (@NotNull Runnable action, @NotNull ProgressIndicator progressIndicator) { ApplicationEx application = (ApplicationEx)ApplicationManager.getApplication(); application.assertIsNonDispatchThread(); Runnable cancellation = indicatorCancellation(progressIndicator); if (isWriteActionRunningOrPending(application)) { cancellation.run(); return false; } return ProgressManager.getInstance().runProcess(() -> { try { // add listener inside runProcess to avoid cancelling indicator before even starting the progress return runActionAndCancelBeforeWrite(application, cancellation, action); } catch (ProcessCanceledException ignore) { return false; } }, progressIndicator); }