public static void performBeforeCommandEnd(@NotNull Runnable task) {
    if (CommandProcessor.getInstance().getCurrentCommand() == null) return;
    MessageBusConnection connection = ApplicationManager.getApplication().getMessageBus().connect();
    connection.subscribe(CommandListener.TOPIC, new CommandListener() {
      @Override
      public void beforeCommandFinished(@NotNull CommandEvent event) {
        task.run();
      }

      @Override
      public void commandFinished(@NotNull CommandEvent event) {
        connection.disconnect();
      }
    });
  }
public static void performBeforeCommandEnd(@NotNull Runnable task)