我正在开发一个与Git一起工作的插件。我想打开Git窗口,并通过提交ID关注一个特殊的提交。我发现我可以用以下代码打开Git窗口:
ProjectLevelVcsManager.getInstance(project).showConsole();
字符串但我不知道如何专注于一个特殊的承诺。
jogvjijk1#
我解决了这个问题,下面是代码:
String commitId = "123456"; //suppose it is commit id VcsLogContentUtil.runInMainLog(project,(logUi) -> jumpToRevisionUnderProgress(project,logUi,commitId)); private void jumpToRevisionUnderProgress(Project project,VcsLogUiEx logUi,String commitId){ //some null check //.... Future<Boolean> future = VcsLogNavigationUtil.jumpToHash(logUi, commitId, false, true); if (!future.isDone()) { ProgressManager.getInstance().run(new Task.Backgroundable(project, "my title", false,PerformInBackgroundOption.ALWAYS_BACKGROUND) { @Override public void run(@NotNull ProgressIndicator indicator) { try { future.get(); } catch (CancellationException | InterruptedException ignored) { } catch (ExecutionException e) { LOG.error(e); } } }); } }
字符串参见IDEA Community
1条答案
按热度按时间jogvjijk1#
我解决了这个问题,下面是代码:
字符串
参见IDEA Community