From 25c9c553c6e3e778f7ee90c42a9ca9f6915def37 Mon Sep 17 00:00:00 2001 From: nightwing Date: Tue, 1 May 2012 15:43:54 +0400 Subject: [PATCH] fix vim mode +cleanup --- lib/ace/keyboard/vim.js | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/lib/ace/keyboard/vim.js b/lib/ace/keyboard/vim.js index e5698913..26016d34 100644 --- a/lib/ace/keyboard/vim.js +++ b/lib/ace/keyboard/vim.js @@ -45,22 +45,22 @@ var coreCommands = cmds.coreCommands; var util = require("./vim/maps/util"); var startCommands = { - 'i': { + "i": { command: coreCommands.start }, - 'I': { + "I": { command: coreCommands.startBeginning }, - 'a': { + "a": { command: coreCommands.append }, - 'A': { + "A": { command: coreCommands.appendEnd }, - 'ctrl-f': { + "ctrl-f": { command: "gotopagedown" }, - 'ctrl-b': { + "ctrl-b": { command: "gotopageup" }, }; @@ -68,15 +68,13 @@ var startCommands = { exports.handler = { handleKeyboard: function(data, hashId, key, keyCode, e) { // ignore command keys (shift, ctrl etc.) - // Otherwise "shift-" is added to the buffer, and later on "shift-g" - // which results in "shift-shift-g" which doesn't make sense. if (hashId != 0 && (key == "" || key == "\x00")) return null; if (hashId == 1) - key = 'ctrl-' + key; + key = "ctrl-" + key; - if (data.state == 'start') { + if (data.state == "start") { if (hashId == -1 || hashId == 1) { if (cmds.inputBuffer.idle && startCommands[key]) return startCommands[key]; @@ -86,13 +84,13 @@ exports.handler = { } }; } // wait for input else if (key.length == 1 && (hashId == 0 || hashId == 4)) { //no modifier || shift - return {command: "null"}; - } else if (key == 'esc') { + return {command: "null", passEvent: true}; + } else if (key == "esc") { return {command: coreCommands.stop}; } } else { - if (key == 'esc' || key == 'ctrl-[') { - data.state = 'start'; + if (key == "esc" || key == "ctrl-[") { + data.state = "start"; return {command: coreCommands.stop}; } else if (key == "ctrl-w") { return {command: "removewordleft"};