From dc86e49dd09c5ffebf8b9dc4c491b73d9e2d139f Mon Sep 17 00:00:00 2001 From: "Gregory.Shrago" Date: Mon, 30 Sep 2019 18:36:32 +0300 Subject: [PATCH] hide some non-applicable keymaps 5 GitOrigin-RevId: 0ff14cd77e4ff3ec2fe225c2fc37e53abd9b5e09 --- .../keymap/impl/DefaultBundledKeymaps.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/DefaultBundledKeymaps.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/DefaultBundledKeymaps.java index b97bb765790b..4ea5e6be9749 100644 --- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/DefaultBundledKeymaps.java +++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/DefaultBundledKeymaps.java @@ -19,9 +19,9 @@ */ package com.intellij.openapi.keymap.impl; +import com.intellij.ide.plugins.IdeaPluginDescriptor; import com.intellij.ide.plugins.PluginManagerCore; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.extensions.PluginId; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; import org.jetbrains.annotations.ApiStatus; @@ -44,17 +44,19 @@ public class DefaultBundledKeymaps implements BundledKeymapProvider { String os = SystemInfo.isMac ? "macos" : SystemInfo.isWindows ? "windows" : SystemInfo.isLinux ? "linux" : "other"; - PluginId coreId = PluginId.getId(PluginManagerCore.CORE_PLUGIN_ID); boolean headless = ApplicationManager.getApplication().isHeadlessEnvironment(); for (BundledKeymapBean bean : BundledKeymapBean.EP_NAME.getExtensionList()) { + IdeaPluginDescriptor plugin = bean.getPluginId() == null ? null : PluginManagerCore.getPlugin(bean.getPluginId()); + String keymapName = FileUtil.getNameWithoutExtension(bean.file); if (bean.file.contains("$OS$")) { // add all OS-specific result.add(bean.file.replace("$OS$", os)); } else if (headless || - !coreId.equals(bean.getPluginId()) || - !isBundledKeymapHidden(FileUtil.getNameWithoutExtension(bean.file))) { - // filter out bundled keymaps for other systems, but allow them via plugins + plugin != null && !plugin.isBundled() && !isBundledMacOSKeymap(keymapName) || + !isBundledKeymapHidden(keymapName)) { + // filter out bundled keymaps for other systems, but allow them via non-bundled plugins + // also skip non-bundled known macOS keymaps on non-macOS systems result.add(bean.file); } } @@ -67,6 +69,11 @@ public class DefaultBundledKeymaps implements BundledKeymapProvider { "Default for GNOME".equals(keymapName) || "Default for KDE".equals(keymapName)) return true; } + if (isBundledMacOSKeymap(keymapName)) return true; + return false; + } + + private static boolean isBundledMacOSKeymap(@Nullable String keymapName) { if (!SystemInfo.isMac) { if ("Mac OS X".equals(keymapName) || "Mac OS X 10.5+".equals(keymapName) ||