Bug 553593 - Inconsistent value of activeMenu variable
Summary: Inconsistent value of activeMenu variable
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.14   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-11-28 13:20 EST by Patrick Tasse CLA
Modified: 2019-11-28 13:20 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.