Allow overrides.json to override default shortcuts. #9858
Merged
+23
−18
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
References
Fixes https://discourse.jupyter.org/t/keyboard-shortcuts-with-overrides-json/5751 and https://discourse.jupyter.org/t/some-configs-in-overrides-json-does-not-work-as-i-intended/3955
Code changes
Shortcuts were throwing away any defaults given by the shortcut plugin settings or overrides.json. This adds them back into the default shortcuts, and also allows default shortcuts to disable each other silently. This allows overrides.json to disable default shortcuts as well as add new default shortcuts.
User-facing changes
Users can override default shortcuts with overrides.json.
This behavior is slightly different than the normal overrides.json behavior. Normally, the overrides.json values overwrite the plugin defaults, so the user never sees the plugin defaults. In this PR, we instead add the overrides.json shortcuts, merging them into the existing defaults, rather than overwriting the existing defaults. I think this makes more sense for shortcuts, which are assembled from many different plugins.
To test, you can create a
dev_mode/settings/overrides.json
file like this:You can know it is active by the default dark theme. Look at the shortcuts, and you'll see the two additional shortcuts, and then try the shortcuts in the imageviewer to verify that "X" now flips horizontally and "H" does not.
Backwards-incompatible changes