Allow defining keyboard shortcuts for missing actions

When users bind custom shortcuts to actions coming from extensions, the
shortcuts can be loaded before the extensions, so we need to allow
defining a shortcut for an action that doesn't exist yet.

Closes gh-3549
Closes gh-2954
This commit is contained in:
Thomas Kluyver 2018-04-24 17:13:05 +02:00
parent 10b7240599
commit 20f1b74ce9

View File

@ -454,7 +454,14 @@ define([
**/
var action_name = this.actions.get_name(data);
if (! action_name){
throw new Error('does not know how to deal with : ' + data);
if (typeof data === 'string') {
// If we have an action name, allow it to be bound anyway.
console.log("Unknown action '" + data + "' for shortcut " + shortcut
+ "; it may be defined by an extension which is not yet loaded.");
action_name = data;
} else {
throw new Error('does not know how to deal with : ' + data);
}
}
var _shortcut = normalize_shortcut(shortcut);
this.set_shortcut(_shortcut, action_name);