@@ -17,7 +17,7 @@ import { ThemeIcon } from 'vs/base/common/themables';
17
17
import { Emitter , Event } from 'vs/base/common/event' ;
18
18
import { KeyCode , KeyMod , ScanCode , ScanCodeUtils } from 'vs/base/common/keyCodes' ;
19
19
import { ResolvedKeybinding } from 'vs/base/common/keybindings' ;
20
- import { Disposable , dispose , IDisposable } from 'vs/base/common/lifecycle' ;
20
+ import { Disposable , DisposableStore , dispose , IDisposable } from 'vs/base/common/lifecycle' ;
21
21
import { isMacintosh } from 'vs/base/common/platform' ;
22
22
import * as strings from 'vs/base/common/strings' ;
23
23
import 'vs/css!./menubar' ;
@@ -87,6 +87,8 @@ export class MenuBar extends Disposable {
87
87
private numMenusShown : number = 0 ;
88
88
private overflowLayoutScheduled : IDisposable | undefined = undefined ;
89
89
90
+ private readonly menuDisposables = this . _register ( new DisposableStore ( ) ) ;
91
+
90
92
constructor ( private container : HTMLElement , private options : IMenuBarOptions , private menuStyle : IMenuStyles ) {
91
93
super ( ) ;
92
94
@@ -751,6 +753,7 @@ export class MenuBar extends Disposable {
751
753
}
752
754
753
755
if ( this . focusedMenu ) {
756
+ this . cleanupCustomMenu ( ) ;
754
757
this . showCustomMenu ( this . focusedMenu . index , this . openedViaKeyboard ) ;
755
758
}
756
759
break ;
@@ -985,6 +988,7 @@ export class MenuBar extends Disposable {
985
988
986
989
this . focusedMenu = { index : this . focusedMenu . index } ;
987
990
}
991
+ this . menuDisposables . clear ( ) ;
988
992
}
989
993
990
994
private showCustomMenu ( menuIndex : number , selectFirst = true ) : void {
@@ -1025,9 +1029,8 @@ export class MenuBar extends Disposable {
1025
1029
useEventAsContext : true
1026
1030
} ;
1027
1031
1028
- const menuWidget = this . _register ( new Menu ( menuHolder , customMenu . actions , menuOptions , this . menuStyle ) ) ;
1029
-
1030
- this . _register ( menuWidget . onDidCancel ( ( ) => {
1032
+ const menuWidget = this . menuDisposables . add ( new Menu ( menuHolder , customMenu . actions , menuOptions , this . menuStyle ) ) ;
1033
+ this . menuDisposables . add ( menuWidget . onDidCancel ( ( ) => {
1031
1034
this . focusState = MenubarState . FOCUSED ;
1032
1035
} ) ) ;
1033
1036
0 commit comments