@@ -19,16 +19,20 @@ import { IdGenerator } from 'vs/base/common/idGenerator';
1919import { createCSSRule } from 'vs/base/browser/dom' ;
2020import URI from 'vs/base/common/uri' ;
2121import { INotificationService } from 'vs/platform/notification/common/notification' ;
22+ import { isWindows } from 'vs/base/common/platform' ;
2223
23- class AltKeyEmitter extends Emitter < boolean > {
24+ // The alternative key on all platforms is alt. On windows we also support shift as an alternative key #44136
25+ class AlternativeKeyEmitter extends Emitter < boolean > {
2426
2527 private _subscriptions : IDisposable [ ] = [ ] ;
2628 private _isPressed : boolean ;
2729
2830 private constructor ( contextMenuService : IContextMenuService ) {
2931 super ( ) ;
3032
31- this . _subscriptions . push ( domEvent ( document . body , 'keydown' ) ( e => this . isPressed = e . altKey ) ) ;
33+ this . _subscriptions . push ( domEvent ( document . body , 'keydown' ) ( e => {
34+ this . isPressed = e . altKey || ( isWindows && e . shiftKey ) ;
35+ } ) ) ;
3236 this . _subscriptions . push ( domEvent ( document . body , 'keyup' ) ( e => this . isPressed = false ) ) ;
3337 this . _subscriptions . push ( domEvent ( document . body , 'mouseleave' ) ( e => this . isPressed = false ) ) ;
3438 this . _subscriptions . push ( domEvent ( document . body , 'blur' ) ( e => this . isPressed = false ) ) ;
@@ -47,7 +51,7 @@ class AltKeyEmitter extends Emitter<boolean> {
4751
4852 @memoize
4953 static getInstance ( contextMenuService : IContextMenuService ) {
50- return new AltKeyEmitter ( contextMenuService ) ;
54+ return new AlternativeKeyEmitter ( contextMenuService ) ;
5155 }
5256
5357 dispose ( ) {
@@ -61,11 +65,11 @@ export function fillInActions(menu: IMenu, options: IMenuActionOptions, target:
6165 if ( groups . length === 0 ) {
6266 return ;
6367 }
64- const altKey = AltKeyEmitter . getInstance ( contextMenuService ) ;
68+ const getAlternativeActions = AlternativeKeyEmitter . getInstance ( contextMenuService ) . isPressed ;
6569
6670 for ( let tuple of groups ) {
6771 let [ group , actions ] = tuple ;
68- if ( altKey . isPressed ) {
72+ if ( getAlternativeActions ) {
6973 actions = actions . map ( a => ! ! a . alt ? a . alt : a ) ;
7074 }
7175
@@ -152,10 +156,10 @@ export class MenuItemActionItem extends ActionItem {
152156 this . _updateItemClass ( this . _action . item ) ;
153157
154158 let mouseOver = false ;
155- let altDown = false ;
159+ let alternativeKeyDown = false ;
156160
157161 const updateAltState = ( ) => {
158- const wantsAltCommand = mouseOver && altDown ;
162+ const wantsAltCommand = mouseOver && alternativeKeyDown ;
159163 if ( wantsAltCommand !== this . _wantsAltCommand ) {
160164 this . _wantsAltCommand = wantsAltCommand ;
161165 this . _updateLabel ( ) ;
@@ -164,8 +168,8 @@ export class MenuItemActionItem extends ActionItem {
164168 }
165169 } ;
166170
167- this . _callOnDispose . push ( AltKeyEmitter . getInstance ( this . _contextMenuService ) . event ( value => {
168- altDown = value ;
171+ this . _callOnDispose . push ( AlternativeKeyEmitter . getInstance ( this . _contextMenuService ) . event ( value => {
172+ alternativeKeyDown = value ;
169173 updateAltState ( ) ;
170174 } ) ) ;
171175
@@ -249,4 +253,4 @@ export class ContextAwareMenuItemActionItem extends MenuItemActionItem {
249253 this . actionRunner . run ( this . _commandAction , this . _context )
250254 . done ( undefined , err => this . _notificationService . error ( err ) ) ;
251255 }
252- }
256+ }
0 commit comments