diff --git a/lib/ace/keyboard/keybinding.js b/lib/ace/keyboard/keybinding.js index 3c79b724..9c54a947 100644 --- a/lib/ace/keyboard/keybinding.js +++ b/lib/ace/keyboard/keybinding.js @@ -103,12 +103,12 @@ var KeyBinding = function(editor) { // allow keyboardHandler to consume keys if (toExecute.command == "null") { - success = toExecute.passEvent != true; + success = true; } else { success = commands.exec(toExecute.command, this.$editor, toExecute.args, e); } // do not stop input events to not break repeating - if (success && e && hashId != -1) + if (success && e && hashId != -1 && toExecute.passEvent != true) event.stopEvent(e); if (success) break; diff --git a/lib/ace/keyboard/vim.js b/lib/ace/keyboard/vim.js index d62f6b3a..417bf556 100644 --- a/lib/ace/keyboard/vim.js +++ b/lib/ace/keyboard/vim.js @@ -85,11 +85,23 @@ exports.handler = { // ignore command keys (shift, ctrl etc.) if (hashId != 0 && (key == "" || key == "\x00")) return null; - + + var editor = data.editor; + if (hashId == 1) key = "ctrl-" + key; - - if ((key == "esc" && hashId == 0) || key == "ctrl-[") { + if (key == "ctrl-c") { + if (!useragent.isMac && editor.getCopyText()) { + editor.once("copy", function() { + if (data.state == "start") + coreCommands.stop.exec(editor); + else + editor.selection.clearSelection(); + }); + return {command: "null", passEvent: true}; + } + return {command: coreCommands.stop}; + } else if ((key == "esc" && hashId == 0) || key == "ctrl-[") { return {command: coreCommands.stop}; } else if (data.state == "start") { if (useragent.isMac && this.handleMacRepeat(data, hashId, key)) { @@ -100,13 +112,8 @@ exports.handler = { if (hashId == -1 || hashId == 1 || hashId == 0 && key.length > 1) { if (cmds.inputBuffer.idle && startCommands[key]) return startCommands[key]; - return { - command: { - exec: function(editor) { - return cmds.inputBuffer.push(editor, key); - } - } - }; + cmds.inputBuffer.push(editor, key); + return {command: "null", passEvent: false}; } // if no modifier || shift: wait for input. else if (key.length == 1 && (hashId == 0 || hashId == 4)) { return {command: "null", passEvent: true}; diff --git a/lib/ace/multi_select.js b/lib/ace/multi_select.js index d1b226f0..d00bfb05 100644 --- a/lib/ace/multi_select.js +++ b/lib/ace/multi_select.js @@ -534,7 +534,7 @@ var Editor = require("./editor").Editor; } else if (!this.selection.isEmpty()) { text = this.session.getTextRange(this.getSelectionRange()); } - + this._signal("copy", text); return text; };