Bug 553593

Summary: Inconsistent value of activeMenu variable
Product: [Eclipse Project] Platform Reporter: Patrick Tasse <patrick.tasse>
Component: UIAssignee: Platform-UI-Inbox <Platform-UI-Inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3    
Version: 4.14   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Patrick Tasse CLA 2019-11-28 13:20:11 EST
We have a contribution in our framework for a command handler for the 'org.eclipse.ui.file.refresh' action, with an 'activeWhen' condition that evaluates the 'selection' variable (priority 1<<30).

Now we have an extension to our framework that wants to contribute a command handler that overrides the one from the framework. It has the same requirements on 'selection' in its 'activeWhen' condition.

So we have conflicting handlers. In order to resolve the conflict, we saw that one handler should have a more specific condition. The only variable that has more priority is 'activeMenu' (priority 1<<31), so we added this condition to the 'activeWhen' expression:

<with variable="activeMenu"><count value="*"></count></with>

This works well when 'Refresh F5' is invoked from the context menu. The extension's handler has priority and executes.

But we have an issue when invoking the command from the 'F5' keyboard shortcut:

After starting Eclipse, when pressing 'F5' the 'activeMenu' variable has the value: HashSet [], which makes our new condition evaluate to true.

But after *any* context menu has been opened at least once, at every subsequent attempt of pressing 'F5' the 'activeMenu' variable has the value: IEvaluationContext.UNDEFINED_VARIABLE, which makes the condition fast-return an evaluation result of false in WithExpression.evaluate().

There seems to be an inconsistency in the value of 'activeMenu' variable depending on whether a context menu has ever been opened or not.

If you have a suggestion for a workaround or a better way to achieve our goal to override a command handler with the same 'selection' condition expression, it would be appreciated.