Bug 968424 - Change keyboard shortcut to move selected lines in source editor to Alt-Up/Down. r=anton, a=sledru
--- a/browser/devtools/sourceeditor/editor.js
+++ b/browser/devtools/sourceeditor/editor.js
@@ -148,18 +148,18 @@ function Editor(config) {
styleActiveLine: true,
autoCloseBrackets: "()[]{}''\"\"",
autoCloseEnabled: useAutoClose,
theme: "mozilla"
};
// Additional shortcuts.
this.config.extraKeys[Editor.keyFor("jumpToLine")] = () => this.jumpToLine();
- this.config.extraKeys[Editor.keyFor("moveLineUp")] = () => this.moveLineUp();
- this.config.extraKeys[Editor.keyFor("moveLineDown")] = () => this.moveLineDown();
+ this.config.extraKeys[Editor.keyFor("moveLineUp", { noaccel: true })] = () => this.moveLineUp();
+ this.config.extraKeys[Editor.keyFor("moveLineDown", { noaccel: true })] = () => this.moveLineDown();
this.config.extraKeys[Editor.keyFor("toggleComment")] = "toggleComment";
// Disable ctrl-[ and ctrl-] because toolbox uses those shortcuts.
this.config.extraKeys[Editor.keyFor("indentLess")] = false;
this.config.extraKeys[Editor.keyFor("indentMore")] = false;
// If alternative keymap is provided, use it.
if (keyMap === "emacs" || keyMap === "vim")
@@ -820,22 +820,23 @@ CM_MAPPING.forEach(function (name) {
Editor.accel = function (key, modifiers={}) {
return (modifiers.shift ? "Shift-" : "") +
(Services.appinfo.OS == "Darwin" ? "Cmd-" : "Ctrl-") +
(modifiers.alt ? "Alt-" : "") + key;
};
/**
* Returns a string representation of a shortcut for a
- * specified command 'cmd'. Cmd- for macs, Ctrl- for other
- * platforms. Useful when overwriting or disabling default
- * shortcuts.
+ * specified command 'cmd'. Append Cmd- for macs, Ctrl- for other
+ * platforms unless noaccel is specified in the options. Useful when overwriting
+ * or disabling default shortcuts.
*/
-Editor.keyFor = function (cmd) {
- return Editor.accel(L10N.GetStringFromName(cmd + ".commandkey"));
+Editor.keyFor = function (cmd, opts={ noaccel: false }) {
+ let key = L10N.GetStringFromName(cmd + ".commandkey");
+ return opts.noaccel ? key : Editor.accel(key);
};
// Since Gecko already provide complete and up to date list of CSS property
// names, values and color names, we compute them so that they can replace
// the ones used in CodeMirror while initiating an editor object. This is done
// here instead of the file codemirror/css.js so as to leave that file untouched
// and easily upgradable.
function getCSSKeywords() {
--- a/browser/locales/en-US/chrome/browser/devtools/sourceeditor.properties
+++ b/browser/locales/en-US/chrome/browser/devtools/sourceeditor.properties
@@ -70,17 +70,15 @@ indentLess.commandkey=[
# LOCALIZATION NOTE (toolboxPrevTool.commandkey): This the key to use in
# conjunction with accel (Command on Mac or Ctrl on other platforms) to increase
# indentation level in CodeMirror. However, its default value also used by
# the Toolbox to switch between tools
#
# DO NOT translate this key without proper synchronization with toolbox.dtd.
indentMore.commandkey=]
-# LOCALIZATION NOTE (moveLineUp.commandkey): This the key to use in
-# conjunction with accel (Command on Mac or Ctrl on other platforms) to move
+# LOCALIZATION NOTE (moveLineUp.commandkey): This is the key to use to move
# the selected lines up.
moveLineUp.commandkey=Alt-Up
-# LOCALIZATION NOTE (moveLineDown.commandkey): This the key to use in
-# conjunction with accel (Command on Mac or Ctrl on other platforms) to move
+# LOCALIZATION NOTE (moveLineDown.commandkey): This is the key to use to move
# the selected lines down.
moveLineDown.commandkey=Alt-Down