diff --git a/lib/ace/keyboard/keybinding.js b/lib/ace/keyboard/keybinding.js index d5edd4f8..c43d7930 100644 --- a/lib/ace/keyboard/keybinding.js +++ b/lib/ace/keyboard/keybinding.js @@ -36,7 +36,7 @@ var event = require("../lib/event"); var KeyBinding = function(editor) { this.$editor = editor; - this.$data = {}; + this.$data = {editor: editor}; this.$handlers = []; this.setDefaultHandler(editor.commands); }; @@ -46,7 +46,6 @@ var KeyBinding = function(editor) { this.removeKeyboardHandler(this.$defaultHandler); this.$defaultHandler = kb; this.addKeyboardHandler(kb, 0); - this.$data = {editor: this.$editor}; }; this.setKeyboardHandler = function(kb) { diff --git a/lib/ace/keyboard/vim.js b/lib/ace/keyboard/vim.js index 8b8bef2c..deea8d2f 100644 --- a/lib/ace/keyboard/vim.js +++ b/lib/ace/keyboard/vim.js @@ -120,23 +120,24 @@ exports.handler = { return null; var editor = data.editor; + var vimState = data.vimState || "start"; if (hashId == 1) key = "ctrl-" + key; if (key == "ctrl-c") { if (!useragent.isMac && editor.getCopyText()) { editor.once("copy", function() { - if (data.state == "start") + if (vimState == "start") coreCommands.stop.exec(editor); else editor.selection.clearSelection(); }); return {command: "null", passEvent: true}; } - return {command: coreCommands.stop}; + return {command: coreCommands.stop}; } else if ((key == "esc" && hashId === 0) || key == "ctrl-[") { return {command: coreCommands.stop}; - } else if (data.state == "start") { + } else if (vimState == "start") { if (useragent.isMac && this.handleMacRepeat(data, hashId, key)) { hashId = -1; key = data.inputChar; diff --git a/lib/ace/keyboard/vim/maps/util.js b/lib/ace/keyboard/vim/maps/util.js index a216c2cc..1eadde84 100644 --- a/lib/ace/keyboard/vim/maps/util.js +++ b/lib/ace/keyboard/vim/maps/util.js @@ -33,7 +33,7 @@ module.exports = { editor.setOverwrite(false); editor.keyBinding.$data.buffer = ""; - editor.keyBinding.$data.state = "insertMode"; + editor.keyBinding.$data.vimState = "insertMode"; this.onVisualMode = false; this.onVisualLineMode = false; if(this.onInsertReplaySequence) { @@ -66,7 +66,7 @@ module.exports = { editor.setOverwrite(true); editor.keyBinding.$data.buffer = ""; - editor.keyBinding.$data.state = "start"; + editor.keyBinding.$data.vimState = "start"; this.onVisualMode = false; this.onVisualLineMode = false; editor._emit("changeStatus");