|
1 | 1 | import * as PQueue from 'p-queue';
|
2 | 2 | import { inject, injectable, postConstruct } from 'inversify';
|
3 |
| -import { MenuPath, SubMenuOptions } from '@theia/core/lib/common/menu'; |
| 3 | +import { MenuPath, SubMenuOptions, CompositeMenuNode } from '@theia/core/lib/common/menu'; |
4 | 4 | import { Disposable, DisposableCollection } from '@theia/core/lib/common/disposable';
|
5 | 5 | import { OpenSketch } from './open-sketch';
|
6 | 6 | import { ArduinoMenus } from '../menu/arduino-menus';
|
@@ -40,6 +40,18 @@ export abstract class Examples extends SketchContribution {
|
40 | 40 | }
|
41 | 41 |
|
42 | 42 | registerMenus(registry: MenuModelRegistry): void {
|
| 43 | + try { |
| 44 | + // This is a hack the ensures the desired menu ordering! We cannot use https://github.com/eclipse-theia/theia/pull/8377 due to ATL-222. |
| 45 | + const index = ArduinoMenus.FILE__EXAMPLES_SUBMENU.length - 1; |
| 46 | + const menuId = ArduinoMenus.FILE__EXAMPLES_SUBMENU[index]; |
| 47 | + const groupPath = index === 0 ? [] : ArduinoMenus.FILE__EXAMPLES_SUBMENU.slice(0, index); |
| 48 | + const parent: CompositeMenuNode = (registry as any).findGroup(groupPath); |
| 49 | + const examples = new CompositeMenuNode(menuId, '', { order: '4' }); |
| 50 | + parent.addNode(examples); |
| 51 | + } catch (e) { |
| 52 | + console.error(e); |
| 53 | + console.warn('Could not patch menu ordering.'); |
| 54 | + } |
43 | 55 | // Registering the same submenu multiple times has no side-effect.
|
44 | 56 | // TODO: unregister submenu? https://github.com/eclipse-theia/theia/issues/7300
|
45 | 57 | registry.registerSubmenu(ArduinoMenus.FILE__EXAMPLES_SUBMENU, 'Examples', { order: '4' });
|
|
0 commit comments