From 1a4c673c82092886e2c284ed65db2555f9e33d7e Mon Sep 17 00:00:00 2001 From: Alexandr Evstigneev Date: Sat, 30 Sep 2023 20:00:33 +0400 Subject: [PATCH] #2644 Added readaction to the cpanminus adapter and adjusted test to single-action --- .../perl5/lang/perl/cpanminus/adapter/CpanminusAdapter.java | 3 ++- plugin/src/test/java/run/PerlRunTest.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/plugin/cpanminus/src/main/java/com/perl5/lang/perl/cpanminus/adapter/CpanminusAdapter.java b/plugin/cpanminus/src/main/java/com/perl5/lang/perl/cpanminus/adapter/CpanminusAdapter.java index 0c6da62f20..8661d1baf4 100644 --- a/plugin/cpanminus/src/main/java/com/perl5/lang/perl/cpanminus/adapter/CpanminusAdapter.java +++ b/plugin/cpanminus/src/main/java/com/perl5/lang/perl/cpanminus/adapter/CpanminusAdapter.java @@ -16,6 +16,7 @@ package com.perl5.lang.perl.cpanminus.adapter; +import com.intellij.openapi.application.ReadAction; import com.intellij.openapi.project.Project; import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.util.NlsSafe; @@ -85,7 +86,7 @@ public static boolean isAvailable(@Nullable Project project) { public static final class Factory implements PackageManagerAdapterFactory { @Override public @Nullable CpanminusAdapter createAdapter(@NotNull Sdk sdk, @Nullable Project project) { - return isAvailable(project) ? new CpanminusAdapter(sdk, project) : null; + return ReadAction.compute(() -> isAvailable(project) ? new CpanminusAdapter(sdk, project) : null); } @VisibleForTesting diff --git a/plugin/src/test/java/run/PerlRunTest.java b/plugin/src/test/java/run/PerlRunTest.java index 44c324563f..b0d160dddb 100644 --- a/plugin/src/test/java/run/PerlRunTest.java +++ b/plugin/src/test/java/run/PerlRunTest.java @@ -133,7 +133,7 @@ public void testMissingPackageNotification() { assertNotNull(notification); assertEquals(PerlBundle.message("perl.missing.library.notification"), notification.getGroupId()); assertEquals(PerlBundle.message("perl.missing.library.notification.title", "Some::Missing::Module"), notification.getTitle()); - assertSize(2, notification.getActions()); + assertSize(1, notification.getActions()); assertEquals(PerlBundle.message("perl.missing.library.notification.message"), notification.getContent()); }