diff --git a/common/content/editor.js b/common/content/editor.js index fbc79505..483c31dd 100644 --- a/common/content/editor.js +++ b/common/content/editor.js @@ -678,11 +678,10 @@ const Editor = Module("editor", { }); mappings.add([modes.VISUAL], - ["d"], "Delete selected text", + ["d", "x"], "Delete selected text", function () { dactyl.assert(editor.isTextEdit); editor.executeCommand("cmd_cut"); - modes.pop(); }); mappings.add([modes.VISUAL], diff --git a/common/content/events.js b/common/content/events.js index 3e99b85c..0a8fca7a 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -969,7 +969,7 @@ const Events = Module("events", { this._input.motionCount = null; if (!isEscape(key)) { - stop = (mode.main == modes.TEXT_EDIT); + stop = (mode.main & (modes.TEXT_EDIT | modes.VISUAL)); if (stop) dactyl.beep(); diff --git a/common/content/mappings.js b/common/content/mappings.js index a1681aa1..455f7c30 100644 --- a/common/content/mappings.js +++ b/common/content/mappings.js @@ -373,21 +373,17 @@ const Mappings = Module("mappings", { Command.bindMacro(args, "-keys", ["count"]), { count: args["-count"], - noremap: "-builtin" in args, + noremap: args["-builtin"], persist: !args["-nopersist"], get rhs() String(this.action), - silent: "-silent" in args + silent: args["-silent"] }); } } - modeDescription = modeDescription ? " in " + modeDescription + " mode" : ""; - function findMode(name) { - if (isinstance(name, Number)) - return name; for (let mode in modes.mainModes) - if (name == mode.char || name == mode.name.toLowerCase()) + if (name == mode || name == mode.char || String.toLowerCase(name).replace(/-/g, "_") == mode.name.toLowerCase()) return mode.mask; return null; } @@ -439,7 +435,7 @@ const Mappings = Module("mappings", { description: "Create this mapping in the given modes", default: mapmodes || ["n", "v"], validator: function (list) !list || list.every(findMode), - completer: function () [[array.compact([mode.name.toLowerCase(), mode.char]), mode.disp] + completer: function () [[array.compact([mode.name.toLowerCase().replace(/_/g, "-"), mode.char]), mode.disp] for (mode in modes.mainModes)], }, { @@ -478,6 +474,7 @@ const Mappings = Module("mappings", { yield map; } + modeDescription = modeDescription ? " in " + modeDescription + " mode" : ""; commands.add([ch ? ch + "m[ap]" : "map"], "Map a key sequence" + modeDescription, function (args) { map(args, false); }, diff --git a/common/content/modes.js b/common/content/modes.js index 594646c3..1e66cb1f 100644 --- a/common/content/modes.js +++ b/common/content/modes.js @@ -154,7 +154,7 @@ const Modes = Module("modes", { disp: disp, extended: extended, input: false, - mask: this[name], + mask: mode, name: name, params: params || {} }, options);