From 9c6bf61d7ffe7482e6980ddc45039a1a36a83abc Mon Sep 17 00:00:00 2001 From: "Gregory.Shrago" Date: Wed, 3 Apr 2024 05:31:52 +0400 Subject: [PATCH] remove exact matches without template text by index check In RemDev, on frontend, we do `(merge (customize (merge (front back))) customized-on-backend (back))` children. Due to the merge, `ActionUrl.absolutePosition` can be incorrect. But we can customize backend actions on frontend. That would not be possible if we did `(merge (customize (front)) customized-on-backend (back))`. Fixes GTW-7803 Broken customized menu in Split Mode: Services in Tools case GitOrigin-RevId: 9ef937a98324f60287392077fd107c88fa04b86c --- .../ui/customization/CustomizationUtil.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ide/ui/customization/CustomizationUtil.java b/platform/platform-impl/src/com/intellij/ide/ui/customization/CustomizationUtil.java index 0325dda1bb08..7a75dec80bc1 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/customization/CustomizationUtil.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/customization/CustomizationUtil.java @@ -113,27 +113,28 @@ public final class CustomizationUtil { } AnAction ca = actionUrl.getComponentAction(); if (ca == null) continue; + int position = actionUrl.getAbsolutePosition(); if (actionUrl.getActionType() == ActionUrl.ADDED) { if (ca == group) { LOG.error("Attempt to add group to itself; group ID=" + actionManager.getId(group)); continue; } - if (reorderedChildren.size() > actionUrl.getAbsolutePosition()) { - reorderedChildren.add(actionUrl.getAbsolutePosition(), ca); + if (reorderedChildren.size() > position) { + reorderedChildren.add(position, ca); } else { reorderedChildren.add(ca); } } - else if (actionUrl.getActionType() == ActionUrl.DELETED && reorderedChildren.size() > actionUrl.getAbsolutePosition()) { - AnAction ra = reorderedChildren.get(actionUrl.getAbsolutePosition()); - Presentation rt = ra.getTemplatePresentation(); - Presentation ct = ca.getTemplatePresentation(); - if (rt.getText() == null ? !(ct.getText() == null || ct.getText().isEmpty()) - : !rt.getText().equals(ct.getText())) { - continue; + else if (actionUrl.getActionType() == ActionUrl.DELETED) { + if (!reorderedChildren.remove(ca)) { + AnAction ra = reorderedChildren.get(position); + Presentation rt = ra.getTemplatePresentation(); + Presentation ct = ca.getTemplatePresentation(); + if (rt.getText() == null ? StringUtil.isEmpty(ct.getText()) : rt.getText().equals(ct.getText())) { + reorderedChildren.remove(position); + } } - reorderedChildren.remove(actionUrl.getAbsolutePosition()); } } for (int i = 0; i < reorderedChildren.size(); i++) {