-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Refactor core keyboard bindings into an external json file #2131
Conversation
Thinking about the ultimate goal of user-configurable bindings, it seems like two important things we'd need to handle are: upgrading to a later version of Brackets; and shortcuts related to extensions. I think we might be able to kill both birds with one stone if we tweaked it as follows:
For the purposes of this pull request, I imagine we could punt on all of that. Except I'd suggest we name the folder something like "config" instead of "prefs" to avoid confusion. |
I like all those ideas. :) My idea was to make the first step to externalize the settings. Baby steps. |
Yep, definitely agree. What do you think about the folder rename? |
I think maybe defaults/keyboard.json instead of config/keyboard.json. |
That sounds good to me. |
One general question: is there a reason why the JSON file has each keyboard shortcut map to an object with a single field ( |
Also agree that we should change the folder name to "defaults". |
} | ||
|
||
var defaultBinding = KeyboardPrefs[commandID]; | ||
keyBindings = keyBindings || (defaultBinding ? defaultBinding.keyBindings : undefined); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given this refactoring, it seems a little weird that you now have to call addBinding()
with a null/undefined keyBindings
in order to get the default keybinding applied (in other words, the default keybinding happens as a side-effect of the associated menu item being added, or of someone explicitly calling addBinding()
on the command). It would make more sense to just have some separate place during initialization where we load all the default keybindings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I've changed this to instead add the default bindings when a command is registered.
Initial review done--a few general comments. I didn't review the extraction of each keybinding--do you think it would be valuable for me to do that? |
Waiting for sprint 18 before merging this in. |
…ult key bindings on commandRegistered
Changes pushed. Ready for review after sprint 17. |
Conflicts: src/command/Menus.js
@njx merged sprint 17. Ready for review. |
Looks good, merging. |
Refactor core keyboard bindings into an external json file
Defines a new top level
prefs
folder that contains akeyboard.json
file. This file was generated from the default keybindings in Brackets.KeyBindingManager
loads this json file and queries it for default bindings based on the command ID.