@Override
  public void doWhenFocusSettlesDown(@NotNull Runnable runnable, @NotNull ModalityState modality) {
    // Immediate check is buggy.
    // JVM can run "postponed" code on other thread before this thread set `immediate` to `false`
    AtomicBoolean immediate = new AtomicBoolean(true);
    IdeEventQueue.getInstance().executeWhenAllFocusEventsLeftTheQueue((ContextAwareRunnable) () -> {
      if (immediate.get()) {
        boolean expired = runnable instanceof ExpirableRunnable && ((ExpirableRunnable)runnable).isExpired();
        if (!expired) {
          // Even immediate code need explicit write-safe context, not implicit one
          WriteIntentReadAction.run(runnable);
        }
      }
      else {
        // "Write-safe context" when postponed due to `TransactionGuardImpl#wrapLaterInvocation`
        ApplicationManager.getApplication().invokeLater((ContextAwareRunnable) () -> doWhenFocusSettlesDown(runnable, modality), modality);
      }
    });
    immediate.set(false);
  }
@Override
  public void doWhenFocusSettlesDown(@NotNull Runnable runnable, @NotNull ModalityState modality)