From 6779b93ce8cbc5b9c0e669c9647e3f94da050bfd Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Wed, 15 Feb 2017 14:56:42 +0300 Subject: [PATCH] ui: stabilize action position in Keymap tree This fix affects actions without default text/description set in a plugin.xml or ActionsBundle. Text/description might be initialised in AnAction constructor, and thus be empty in StubAction. Some ActionGroup might contain stub action, even if it was already loaded. While collecting actions for "Other" group we will load non-stub version of an action, and it will pass the filter. Thus, prior to this fix, AnAction might change its place in a tree depending on whether text filter was used or not. And, in some cases, depending on the filter itself - as it could've match internal action id. --- .../openapi/keymap/impl/ui/ActionsTreeUtil.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ActionsTreeUtil.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ActionsTreeUtil.java index 8b296b22a868..32aa38c8e74b 100644 --- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ActionsTreeUtil.java +++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ActionsTreeUtil.java @@ -507,6 +507,8 @@ public class ActionsTreeUtil { return action -> { if (filter == null) return true; if (action == null) return false; + action = tryUnstubAction(action); + final String insensitiveFilter = filter.toLowerCase(); ArrayList options = new ArrayList<>(); options.add(action.getTemplatePresentation().getText()); @@ -597,4 +599,13 @@ public class ActionsTreeUtil { ? ((DefaultActionGroup)group).getChildActionsOrStubs() : group.getChildren(null); } + + @NotNull + private static AnAction tryUnstubAction(@NotNull AnAction action) { + if (action instanceof ActionStub) { + AnAction newAction = ActionManager.getInstance().getActionOrStub(((ActionStub)action).getId()); + if (newAction != null) return newAction; + } + return action; + } }