@@ -82,7 +82,7 @@ public class BindingTableTests {
82
82
"M1+X" , ID_WINDOW , PASTE_ID , "M1+V" , ID_WINDOW , REFRESH_ID , "F5" ,
83
83
ID_DIALOG_AND_WINDOW , EXIT_ID , "CTRL+Q" , ID_DIALOG_AND_WINDOW ,
84
84
ABOUT_ID , "CTRL+5 A" , ID_DIALOG_AND_WINDOW , TAG_ID , "ALT+/" ,
85
- ID_TEXT , RENAME_ID , "F2" , ID_WINDOW , SHOW_TOOLTIP_ID , "F2" ,
85
+ ID_TEXT , RENAME_ID , "F2" , ID_WINDOW , RENAME_ID , "M2+M3+R" , ID_TEXT , SHOW_TOOLTIP_ID , "F2" ,
86
86
ID_TEXT , CORR_INDENT_ID , "CTRL+I" , ID_JAVA , INDENT_LINE_ID ,
87
87
"CTRL+I" , ID_JS , PASTE_ID , "SHIFT+Insert" , ID_WINDOW , PASTE_ID ,
88
88
"CTRL+5 V" , ID_TEXT , };
@@ -317,6 +317,30 @@ public void testManagerLookupShortcut() throws Exception {
317
317
assertEquals (paste , match );
318
318
}
319
319
320
+ @ Test
321
+ public void testManagerLookupShortcutDeeperContext () throws Exception {
322
+ BindingTableManager manager = createManager ();
323
+ // Given a BindingTableManager with default active scheme and context manager:
324
+ manager .setActiveSchemes (new String [] { "org.eclipse.ui.defaultAcceleratorConfiguration" }, contextManager );
325
+ Binding paste = getTestBinding (RENAME_ID , ID_TEXT );
326
+ assertNotNull (paste );
327
+
328
+ ArrayList <Context > window = new ArrayList <>();
329
+ Context winContext = contextManager .getContext (ID_WINDOW );
330
+ Context dawContext = contextManager .getContext (ID_TEXT );
331
+ window .add (winContext );
332
+ window .add (dawContext );
333
+ ContextSet windowSet = manager .createContextSet (window );
334
+ // When getting the best sequence for the paste command:
335
+ Binding match = manager .getBestSequenceFor (windowSet , paste .getParameterizedCommand ());
336
+ // Then the paste binding with the ID_TEXT context should be returned, because
337
+ // it's more specific than the ID_WINDOW context:
338
+ assertEquals (paste , match );
339
+
340
+ // disable context manager in BindingComparator for other tests:
341
+ manager .setActiveSchemes (null , null );
342
+ }
343
+
320
344
@ Test
321
345
public void testManagerLookupShortcutLongChain () throws Exception {
322
346
BindingTableManager manager = createManager ();
@@ -387,6 +411,16 @@ private Binding getTestBinding(String commandId) {
387
411
return null ;
388
412
}
389
413
414
+ private Binding getTestBinding (String commandId , String contextId ) {
415
+ for (Binding binding : loadedBindings ) {
416
+ if (commandId .equals (binding .getParameterizedCommand ().getId ())
417
+ && contextId .equals (binding .getContextId ())) {
418
+ return binding ;
419
+ }
420
+ }
421
+ return null ;
422
+ }
423
+
390
424
private void assertContextSet (ContextSet set , String [] contextIds ) {
391
425
List <Context > contexts = set .getContexts ();
392
426
assertEquals (contextIds .length , contexts .size (), contexts .toString ());
0 commit comments