Bug 1463674 - Allow sourceeditor consumer to have <kbd>Tab</kbd> handling; r=bgrins.
Since the source editor already defines its own extraKeys.Tab,
anything the consumer set was ignored.
This patch now also runs consumer extraKeys.Tab if defined.
MozReview-Commit-ID: 5FeMXoystAb
--- a/devtools/client/sourceeditor/editor.js
+++ b/devtools/client/sourceeditor/editor.js
@@ -174,16 +174,26 @@ function Editor(config) {
// Remember the initial value of autoCloseBrackets.
this.config.autoCloseBracketsSaved = this.config.autoCloseBrackets;
// Overwrite default tab behavior. If something is selected,
// indent those lines. If nothing is selected and we're
// indenting with tabs, insert one tab. Otherwise insert N
// whitespaces where N == indentUnit option.
this.config.extraKeys.Tab = cm => {
+ if (config.extraKeys && config.extraKeys.Tab) {
+ // If a consumer registers its own extraKeys.Tab, we execute it before doing
+ // anything else. If it returns false, that mean that all the key handling work is
+ // done, so we can do an early return.
+ const res = config.extraKeys.Tab(cm);
+ if (res === false) {
+ return;
+ }
+ }
+
if (cm.somethingSelected()) {
cm.indentSelection("add");
return;
}
if (this.config.indentWithTabs) {
cm.replaceSelection("\t", "end", "+input");
return;