Skip to content

Commit 2f8e28b

Browse files
Akos Kittakittaakos
Akos Kitta
authored andcommitted
Patched the menu ordering. (Workaround for eclipse-theia/theia#8377)
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
1 parent 524fbbd commit 2f8e28b

File tree

1 file changed

+13
-1
lines changed
  • arduino-ide-extension/src/browser/contributions

1 file changed

+13
-1
lines changed

arduino-ide-extension/src/browser/contributions/examples.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as PQueue from 'p-queue';
22
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';
44
import { Disposable, DisposableCollection } from '@theia/core/lib/common/disposable';
55
import { OpenSketch } from './open-sketch';
66
import { ArduinoMenus } from '../menu/arduino-menus';
@@ -40,6 +40,18 @@ export abstract class Examples extends SketchContribution {
4040
}
4141

4242
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+
}
4355
// Registering the same submenu multiple times has no side-effect.
4456
// TODO: unregister submenu? https://github.com/eclipse-theia/theia/issues/7300
4557
registry.registerSubmenu(ArduinoMenus.FILE__EXAMPLES_SUBMENU, 'Examples', { order: '4' });

0 commit comments

Comments
 (0)