mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
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.
This commit is contained in:
@@ -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<String> 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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user