@@ -19,7 +19,7 @@ import { addDisposableListener, append, EventType, isAncestor, $, clearNode } fr
1919import { assertIsDefined } from '../../../../base/common/types.js' ;
2020import { CustomMenubarControl } from '../titlebar/menubarControl.js' ;
2121import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js' ;
22- import { getMenuBarVisibility } from '../../../../platform/window/common/window.js' ;
22+ import { getMenuBarVisibility , MenuSettings } from '../../../../platform/window/common/window.js' ;
2323import { IAction , Separator , SubmenuAction , toAction } from '../../../../base/common/actions.js' ;
2424import { StandardKeyboardEvent } from '../../../../base/browser/keyboardEvent.js' ;
2525import { KeyCode } from '../../../../base/common/keyCodes.js' ;
@@ -194,7 +194,7 @@ export class ActivityBarCompositeBar extends PaneCompositeBar {
194194
195195 private element : HTMLElement | undefined ;
196196
197- private menuBar : CustomMenubarControl | undefined ;
197+ private readonly menuBar = this . _register ( new MutableDisposable < CustomMenubarControl > ( ) ) ;
198198 private menuBarContainer : HTMLElement | undefined ;
199199 private compositeBarContainer : HTMLElement | undefined ;
200200 private readonly globalCompositeBar : GlobalCompositeBar | undefined ;
@@ -231,7 +231,7 @@ export class ActivityBarCompositeBar extends PaneCompositeBar {
231231
232232 // Register for configuration changes
233233 this . _register ( this . configurationService . onDidChangeConfiguration ( e => {
234- if ( e . affectsConfiguration ( 'window.menuBarVisibility' ) ) {
234+ if ( e . affectsConfiguration ( MenuSettings . MenuBarVisibility ) ) {
235235 if ( getMenuBarVisibility ( this . configurationService ) === 'compact' ) {
236236 this . installMenubar ( ) ;
237237 } else {
@@ -245,12 +245,12 @@ export class ActivityBarCompositeBar extends PaneCompositeBar {
245245 // Menu
246246 const menuBarVisibility = getMenuBarVisibility ( this . configurationService ) ;
247247 if ( menuBarVisibility === 'compact' || menuBarVisibility === 'hidden' || menuBarVisibility === 'toggle' ) {
248- actions . unshift ( ...[ toAction ( { id : 'toggleMenuVisibility' , label : localize ( 'menu' , "Menu" ) , checked : menuBarVisibility === 'compact' , run : ( ) => this . configurationService . updateValue ( 'window.menuBarVisibility' , menuBarVisibility === 'compact' ? 'toggle' : 'compact' ) } ) , new Separator ( ) ] ) ;
248+ actions . unshift ( ...[ toAction ( { id : 'toggleMenuVisibility' , label : localize ( 'menu' , "Menu" ) , checked : menuBarVisibility === 'compact' , run : ( ) => this . configurationService . updateValue ( MenuSettings . MenuBarVisibility , menuBarVisibility === 'compact' ? 'toggle' : 'compact' ) } ) , new Separator ( ) ] ) ;
249249 }
250250
251251 if ( menuBarVisibility === 'compact' && this . menuBarContainer && e ?. target ) {
252252 if ( isAncestor ( e . target as Node , this . menuBarContainer ) ) {
253- actions . unshift ( ...[ toAction ( { id : 'hideCompactMenu' , label : localize ( 'hideMenu' , "Hide Menu" ) , run : ( ) => this . configurationService . updateValue ( 'window.menuBarVisibility' , 'toggle' ) } ) , new Separator ( ) ] ) ;
253+ actions . unshift ( ...[ toAction ( { id : 'hideCompactMenu' , label : localize ( 'hideMenu' , "Hide Menu" ) , run : ( ) => this . configurationService . updateValue ( MenuSettings . MenuBarVisibility , 'toggle' ) } ) , new Separator ( ) ] ) ;
254254 }
255255 }
256256
@@ -264,9 +264,8 @@ export class ActivityBarCompositeBar extends PaneCompositeBar {
264264 }
265265
266266 private uninstallMenubar ( ) {
267- if ( this . menuBar ) {
268- this . menuBar . dispose ( ) ;
269- this . menuBar = undefined ;
267+ if ( this . menuBar . value ) {
268+ this . menuBar . value = undefined ;
270269 }
271270
272271 if ( this . menuBarContainer ) {
@@ -276,7 +275,7 @@ export class ActivityBarCompositeBar extends PaneCompositeBar {
276275 }
277276
278277 private installMenubar ( ) {
279- if ( this . menuBar ) {
278+ if ( this . menuBar . value ) {
280279 return ; // prevent menu bar from installing twice #110720
281280 }
282281
@@ -293,8 +292,8 @@ export class ActivityBarCompositeBar extends PaneCompositeBar {
293292 /* above codes are changed by github1s */
294293
295294 // Menubar: install a custom menu bar depending on configuration
296- this . menuBar = this . _register ( this . instantiationService . createInstance ( CustomMenubarControl ) ) ;
297- this . menuBar . create ( this . menuBarContainer ) ;
295+ this . menuBar . value = this . _register ( this . instantiationService . createInstance ( CustomMenubarControl ) ) ;
296+ this . menuBar . value . create ( this . menuBarContainer ) ;
298297
299298 }
300299
@@ -318,7 +317,7 @@ export class ActivityBarCompositeBar extends PaneCompositeBar {
318317 if ( kbEvent . equals ( KeyCode . DownArrow ) || kbEvent . equals ( KeyCode . RightArrow ) ) {
319318 this . globalCompositeBar ?. focus ( ) ;
320319 } else if ( kbEvent . equals ( KeyCode . UpArrow ) || kbEvent . equals ( KeyCode . LeftArrow ) ) {
321- this . menuBar ?. toggleFocus ( ) ;
320+ this . menuBar . value ?. toggleFocus ( ) ;
322321 }
323322 } ) ) ;
324323 }
0 commit comments