summaryrefslogtreecommitdiff
path: root/public/vendor/codemirror/keymap/vim.js
diff options
context:
space:
mode:
authorYukai Huang2016-10-11 18:39:15 +0800
committerYukai Huang2016-10-11 18:40:23 +0800
commit6e651c8108783d224c5f40d1bb8047a9ebbeff00 (patch)
treec7d501cc6ebb46399c397768b3f58ef05034c522 /public/vendor/codemirror/keymap/vim.js
parent21028c57735028574c769fb6650322eb3f0cb924 (diff)
parentcd9f8fe36b707ff5a9f8f7be4d55145ddee97f3a (diff)
Merge branch 'master' into webpack-frontend
Diffstat (limited to 'public/vendor/codemirror/keymap/vim.js')
-rw-r--r--public/vendor/codemirror/keymap/vim.js20
1 files changed, 16 insertions, 4 deletions
diff --git a/public/vendor/codemirror/keymap/vim.js b/public/vendor/codemirror/keymap/vim.js
index afed132e..a166f72b 100644
--- a/public/vendor/codemirror/keymap/vim.js
+++ b/public/vendor/codemirror/keymap/vim.js
@@ -780,8 +780,12 @@
if (lastInsertModeKeyTimer) { window.clearTimeout(lastInsertModeKeyTimer); }
if (keysAreChars) {
- var here = cm.getCursor();
- cm.replaceRange('', offsetCursor(here, 0, -(keys.length - 1)), here, '+input');
+ var selections = cm.listSelections();
+ for (var i = 0; i < selections.length; i++) {
+ var here = selections[i].head;
+ cm.replaceRange('', offsetCursor(here, 0, -(keys.length - 1)), here, '+input');
+ }
+ vimGlobalState.macroModeState.lastInsertModeChanges.changes.pop();
}
clearInputState(cm);
return match.command;
@@ -818,7 +822,7 @@
// TODO: Look into using CodeMirror's multi-key handling.
// Return no-op since we are caching the key. Counts as handled, but
// don't want act on it just yet.
- return function() {};
+ return function() { return true; };
} else {
return function() {
return cm.operation(function() {
@@ -4874,6 +4878,10 @@
if (changeObj.origin == '+input' || changeObj.origin == 'paste'
|| changeObj.origin === undefined /* only in testing */) {
var text = changeObj.text.join('\n');
+ if (lastChange.maybeReset) {
+ lastChange.changes = [];
+ lastChange.maybeReset = false;
+ }
lastChange.changes.push(text);
}
// Change objects may be chained with next.
@@ -4896,7 +4904,7 @@
lastChange.expectCursorActivityForChange = false;
} else {
// Cursor moved outside the context of an edit. Reset the change.
- lastChange.changes = [];
+ lastChange.maybeReset = true;
}
} else if (!cm.curOp.isVimOp) {
handleExternalSelection(cm, vim);
@@ -4960,6 +4968,10 @@
var keyName = CodeMirror.keyName(e);
if (!keyName) { return; }
function onKeyFound() {
+ if (lastChange.maybeReset) {
+ lastChange.changes = [];
+ lastChange.maybeReset = false;
+ }
lastChange.changes.push(new InsertModeKey(keyName));
return true;
}