From 306e56dea5e7518ea383a0cbbe33a6b56aabb10c Mon Sep 17 00:00:00 2001
From: Mikhail Sokolov <mikhail.sokolov@jetbrains.com>
Date: Tue, 19 Jun 2018 17:39:02 +0300
Subject: [PATCH] IDEA-194169 New SE: Keyboard shortcut settings

---
 .../src/com/intellij/ide/actions/SetShortcutAction.java  | 9 ++++++++-
 platform/platform-resources/src/idea/PlatformActions.xml | 5 +----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/platform/lang-impl/src/com/intellij/ide/actions/SetShortcutAction.java b/platform/lang-impl/src/com/intellij/ide/actions/SetShortcutAction.java
index da43b7111cc5..4d87dc9d40db 100644
--- a/platform/lang-impl/src/com/intellij/ide/actions/SetShortcutAction.java
+++ b/platform/lang-impl/src/com/intellij/ide/actions/SetShortcutAction.java
@@ -27,7 +27,6 @@ public class SetShortcutAction extends AnAction implements DumbAware {
     if (seDialog == null) {
       return;
     }
-    seDialog.cancel();
 
     KeymapManager km = KeymapManager.getInstance();
     Keymap activeKeymap = km != null ? km.getActiveKeymap() : null;
@@ -41,6 +40,7 @@ public class SetShortcutAction extends AnAction implements DumbAware {
       return;
     }
 
+    seDialog.cancel();
     String id = ActionManager.getInstance().getId(action);
     KeymapPanel.addKeyboardShortcut(id, ActionShortcutRestrictions.getInstance().getForActionId(id), activeKeymap, component);
   }
@@ -56,6 +56,13 @@ public class SetShortcutAction extends AnAction implements DumbAware {
       return;
     }
 
+    KeymapManager km = KeymapManager.getInstance();
+    Keymap activeKeymap = km != null ? km.getActiveKeymap() : null;
+    if (activeKeymap == null) {
+      presentation.setEnabled(false);
+      return;
+    }
+
     AnAction action = e.getData(SELECTED_ACTION);
     Component component = e.getData(PlatformDataKeys.CONTEXT_COMPONENT);
     presentation.setEnabled(action != null && component != null);
diff --git a/platform/platform-resources/src/idea/PlatformActions.xml b/platform/platform-resources/src/idea/PlatformActions.xml
index 512833d914d2..e8444784baa6 100644
--- a/platform/platform-resources/src/idea/PlatformActions.xml
+++ b/platform/platform-resources/src/idea/PlatformActions.xml
@@ -896,9 +896,6 @@
     <action id="MarkNotificationsAsRead" class="com.intellij.notification.impl.actions.MarkAllNotificationsAsReadAction"/>
     <action class="com.intellij.ide.actions.SelectInProjectViewAction" id="SelectInProjectView" text="Select in Project View" />
 
-    <action id="SetShortcutAction"
-            class="com.intellij.ide.actions.SetShortcutAction"
-            use-shortcut-of="ShowIntentionActions"
-    />
+    <action id="SetShortcutAction" class="com.intellij.ide.actions.SetShortcutAction" use-shortcut-of="ShowIntentionActions"/>
   </actions>
 </idea-plugin>
-- 
GitLab