void () { ApplicationManager.getApplication().getMessageBus().connect(myProject).subscribe(AnActionListener.TOPIC, new AnActionListener() { @Override public void beforeActionPerformed(@NotNull AnAction action, @NotNull AnActionEvent event) { cancelAllRequests(); } @Override public void beforeEditorTyping(char c, @NotNull DataContext dataContext) { cancelAllRequests(); } }); IdeEventQueue.getInstance().addActivityListener(this::cancelAllRequests, myProject); }