diff --git a/lib/ace/keyboard/vim.js b/lib/ace/keyboard/vim.js index 0477dca0..8b8bef2c 100644 --- a/lib/ace/keyboard/vim.js +++ b/lib/ace/keyboard/vim.js @@ -149,12 +149,13 @@ exports.handler = { if (!isHandled && hashId !== -1) return; return {command: "null", passEvent: !isHandled}; - } // if no modifier || shift: wait for input. - else if (key.length == 1 && (hashId === 0 || hashId == 4)) { - return {command: "null", passEvent: true}; } else if (key == "esc" && hashId === 0) { return {command: coreCommands.stop}; } + // if no modifier || shift: wait for input. + else if (hashId === 0 || hashId == 4) { + return {command: "null", passEvent: true}; + } } else { if (key == "ctrl-w") { return {command: "removewordleft"}; diff --git a/lib/ace/keyboard/vim/commands.js b/lib/ace/keyboard/vim/commands.js index 1ab154c5..abf04ef9 100644 --- a/lib/ace/keyboard/vim/commands.js +++ b/lib/ace/keyboard/vim/commands.js @@ -123,10 +123,12 @@ var actions = exports.actions = { range.end.column++; var text = editor.session.getTextRange(range); var toggled = text.toUpperCase(); - if (toggled == text) - editor.navigateRight(); - else + if (toggled != text) editor.session.replace(range, toggled); + else if (text.toLowerCase() != text) + editor.session.replace(range, text.toLowerCase()) + else + editor.navigateRight(); }, count || 1); } }, @@ -342,6 +344,7 @@ var inputBuffer = exports.inputBuffer = { currentCmd: null, //currentMode: 0, currentCount: "", + pendingCount: "", status: "", // Types @@ -442,8 +445,9 @@ var inputBuffer = exports.inputBuffer = { }, getCount: function() { - var count = this.currentCount; + var count = this.currentCount || this.pendingCount; this.currentCount = ""; + this.pendingCount = count; return count && parseInt(count, 10); }, @@ -520,6 +524,7 @@ var inputBuffer = exports.inputBuffer = { this.operator = null; this.motion = null; this.currentCount = ""; + this.pendingCount = ""; this.status = ""; this.accepting = [NUMBER, OPERATOR, MOTION, ACTION]; this.idle = true; diff --git a/lib/ace/keyboard/vim/maps/motions.js b/lib/ace/keyboard/vim/maps/motions.js index 90a7a933..26c20237 100644 --- a/lib/ace/keyboard/vim/maps/motions.js +++ b/lib/ace/keyboard/vim/maps/motions.js @@ -387,6 +387,7 @@ module.exports = { param: true, handlesCount: true, getPos: function(editor, range, count, param, isSel, isRepeat) { + if (param == "space") param = " "; if (!isRepeat) LAST_SEARCH_MOTION = {ch: "f", param: param}; var cursor = editor.getCursorPosition(); @@ -402,6 +403,7 @@ module.exports = { param: true, handlesCount: true, getPos: function(editor, range, count, param, isSel, isRepeat) { + if (param == "space") param = " "; if (!isRepeat) LAST_SEARCH_MOTION = {ch: "F", param: param}; var cursor = editor.getCursorPosition(); @@ -417,6 +419,7 @@ module.exports = { param: true, handlesCount: true, getPos: function(editor, range, count, param, isSel, isRepeat) { + if (param == "space") param = " "; if (!isRepeat) LAST_SEARCH_MOTION = {ch: "t", param: param}; var cursor = editor.getCursorPosition(); @@ -435,6 +438,7 @@ module.exports = { param: true, handlesCount: true, getPos: function(editor, range, count, param, isSel, isRepeat) { + if (param == "space") param = " "; if (!isRepeat) LAST_SEARCH_MOTION = {ch: "T", param: param}; var cursor = editor.getCursorPosition(); diff --git a/lib/ace/keyboard/vim/maps/operators.js b/lib/ace/keyboard/vim/maps/operators.js index a7479acb..350bbd05 100644 --- a/lib/ace/keyboard/vim/maps/operators.js +++ b/lib/ace/keyboard/vim/maps/operators.js @@ -115,8 +115,9 @@ module.exports = { }, fn: function(editor, range, count, param) { count = count || 1; + if (param && param.isLine) + param = "y"; switch (param) { - case param.isLine && param: case "y": var pos = editor.getCursorPosition(); editor.selection.selectLine();