Configuring AnAction to setEnabledAndVisibleBased on Git Repository

已回答

Hi,

I've been working on a plugin where I adjust anAction visibility and enablement based on the current Git repository. Initially, I performed the check in the update method, but then I started running into "Slow operations are prohibited on EDT" errors.

To address this issue, I attempted to utilize a listener to detect changes in the active project and set the current repository accordingly. I experimented with the ApplicationActivationListener, but encountered the same error as it also operates on the EDT as well.

I would greatly appreciate any guidance or alternative approaches you might have to do the check without causing any UI slowness.

Thanks, 
Maria

0

Have you tried

@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
    return ActionUpdateThread.BGT;
}

?

You may try listening on com.intellij.dvcs.repo.VcsRepositoryManager#VCS_REPOSITORY_MAPPING_UPDATED and git4idea.repo.GitRepository#GIT_REPO_CHANGE to store the current repository and then you can just query that in the update method.

0

请先登录再写评论。