mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
If a keystroke is bound to ‘unset!’, omit it in the application menu
Fixes atom/atom-keymap#79 This is more general than I would like. If the keystroke is unset in any context, we err on the side of caution and don’t add it to the application menu for any command. Since our application menu isn’t context aware, this should be good enough for now and solve the 80% case. Someday we should make the application menu update / gray out options when the focused element changes.
This commit is contained in:
@@ -63,6 +63,7 @@ class MenuManager
|
||||
@pendingUpdateOperation = null
|
||||
@template = []
|
||||
atom.keymaps.onDidLoadBundledKeymaps => @loadPlatformItems()
|
||||
atom.keymaps.onDidReloadKeymap => @update()
|
||||
atom.packages.onDidActivateInitialPackages => @sortPackagesMenu()
|
||||
|
||||
# Public: Adds the given items to the application menu.
|
||||
@@ -139,10 +140,19 @@ class MenuManager
|
||||
update: ->
|
||||
clearImmediate(@pendingUpdateOperation) if @pendingUpdateOperation?
|
||||
@pendingUpdateOperation = setImmediate =>
|
||||
keystrokesByCommand = {}
|
||||
includedBindings = []
|
||||
unsetKeystrokes = new Set
|
||||
|
||||
for binding in atom.keymaps.getKeyBindings() when @includeSelector(binding.selector)
|
||||
includedBindings.push(binding)
|
||||
if binding.command is 'unset!'
|
||||
unsetKeystrokes.add(binding.keystrokes)
|
||||
|
||||
keystrokesByCommand = {}
|
||||
for binding in includedBindings when not unsetKeystrokes.has(binding.keystrokes)
|
||||
keystrokesByCommand[binding.command] ?= []
|
||||
keystrokesByCommand[binding.command].unshift binding.keystrokes
|
||||
|
||||
@sendToBrowserProcess(@template, keystrokesByCommand)
|
||||
|
||||
loadPlatformItems: ->
|
||||
|
||||
Reference in New Issue
Block a user