Reliable tool window activation from Switcher
[idea/community.git] / platform / platform-impl / src / com / intellij / ide / actions / Switcher.java
index da824e984c9b16bb6d8f2d72b7526f3a40693926..fa5f71942b89650178d14862d627cadb4aebed64 100644 (file)
@@ -894,9 +894,15 @@ public class Switcher extends AnAction implements DumbAware {
 
     void navigate(final boolean openInNewWindow) {
       final Object[] values = getSelectedList().getSelectedValues();
-      myPopup.closeOk(null);
+      myPopup.cancel(null);
       if (values.length > 0 && values[0] instanceof ToolWindow) {
-        ((ToolWindow)values[0]).activate(null, true, true);
+        final ToolWindow toolWindow = (ToolWindow)values[0];
+        IdeFocusManager.getInstance(project).doWhenFocusSettlesDown(new Runnable() {
+          @Override
+          public void run() {
+            toolWindow.activate(null, true, true);
+          }
+        });
       }
       else {
         IdeFocusManager.getInstance(project).doWhenFocusSettlesDown(new Runnable() {