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
This commit is contained in:
Gregory.Shrago
2024-04-03 13:19:38 +00:00
committed by intellij-monorepo-bot
parent dc6c748ff6
commit 9c6bf61d7f
@@ -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++) {