run EditorFileSwapper's in smart mode (EA-64942 - INRE: FileBasedIndexImpl.handleDumb...
authorpeter <peter@jetbrains.com>
Wed, 18 Feb 2015 16:54:10 +0000 (17:54 +0100)
committerpeter <peter@jetbrains.com>
Wed, 18 Feb 2015 18:26:46 +0000 (19:26 +0100)
platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java

index 9cfd4f89bccd302b25a83b5f3b926f511a568e16..1cf6b6fe56822d69c43871e3f6ace79acd3b4065 100644 (file)
@@ -1848,8 +1848,22 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
   }
 
   private class MyRootsListener extends ModuleRootAdapter {
+    private boolean myScheduled;
+    
     @Override
     public void rootsChanged(ModuleRootEvent event) {
+      if (myScheduled) return;
+      myScheduled = true;
+      DumbService.getInstance(myProject).runWhenSmart(new Runnable() {
+        @Override
+        public void run() {
+          myScheduled = false;
+          handleRootChange();
+        }
+      });
+    }
+
+    private void handleRootChange() {
       EditorFileSwapper[] swappers = Extensions.getExtensions(EditorFileSwapper.EP_NAME);
 
       for (EditorWindow eachWindow : getWindows()) {