Skip to content

Commit 162c8ec

Browse files
authored
Fix the slow operation notification associated with PubRoot (#7885)
This resolves #7792
1 parent 1b7e07d commit 162c8ec

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

flutter-idea/src/io/flutter/pub/PubRoot.java

+12-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.intellij.openapi.actionSystem.CommonDataKeys;
1010
import com.intellij.openapi.actionSystem.LangDataKeys;
1111
import com.intellij.openapi.application.ApplicationManager;
12+
import com.intellij.openapi.application.ReadAction;
1213
import com.intellij.openapi.module.Module;
1314
import com.intellij.openapi.module.ModuleManager;
1415
import com.intellij.openapi.project.Project;
@@ -18,6 +19,7 @@
1819
import com.intellij.openapi.util.Computable;
1920
import com.intellij.openapi.vfs.VirtualFile;
2021
import com.intellij.psi.PsiFile;
22+
import com.intellij.util.concurrency.AppExecutorUtil;
2123
import com.jetbrains.lang.dart.util.DotPackagesFileUtil;
2224
import io.flutter.FlutterUtils;
2325
import org.jetbrains.annotations.NotNull;
@@ -139,13 +141,20 @@ public static PubRoot forDirectory(@Nullable VirtualFile dir) {
139141
if (dir == null || !dir.isDirectory() || dir.getPath().endsWith("/")) {
140142
return null;
141143
}
144+
VirtualFile pubspec = null;
145+
try {
146+
pubspec = ReadAction.nonBlocking(() -> {
147+
return dir.findChild(PUBSPEC_YAML);
148+
}).submit(AppExecutorUtil.getAppExecutorService()).get();
149+
} catch (Exception e) {
150+
// do nothing
151+
}
142152

143-
final VirtualFile pubspec = dir.findChild(PUBSPEC_YAML);
144153
if (pubspec == null || !pubspec.exists() || pubspec.isDirectory()) {
145154
return null;
155+
} else {
156+
return new PubRoot(dir, pubspec);
146157
}
147-
148-
return new PubRoot(dir, pubspec);
149158
}
150159

151160
/**

0 commit comments

Comments
 (0)