Skip to content

Commit

Permalink
Fix the slow operation notification associated with PubRoot (#7885)
Browse files Browse the repository at this point in the history
This resolves #7792
  • Loading branch information
jwren authored Jan 8, 2025
1 parent 1b7e07d commit 162c8ec
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions flutter-idea/src/io/flutter/pub/PubRoot.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.Project;
Expand All @@ -18,6 +19,7 @@
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.util.concurrency.AppExecutorUtil;
import com.jetbrains.lang.dart.util.DotPackagesFileUtil;
import io.flutter.FlutterUtils;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -139,13 +141,20 @@ public static PubRoot forDirectory(@Nullable VirtualFile dir) {
if (dir == null || !dir.isDirectory() || dir.getPath().endsWith("/")) {
return null;
}
VirtualFile pubspec = null;
try {
pubspec = ReadAction.nonBlocking(() -> {
return dir.findChild(PUBSPEC_YAML);
}).submit(AppExecutorUtil.getAppExecutorService()).get();
} catch (Exception e) {
// do nothing
}

final VirtualFile pubspec = dir.findChild(PUBSPEC_YAML);
if (pubspec == null || !pubspec.exists() || pubspec.isDirectory()) {
return null;
} else {
return new PubRoot(dir, pubspec);
}

return new PubRoot(dir, pubspec);
}

/**
Expand Down

0 comments on commit 162c8ec

Please sign in to comment.