summaryrefslogtreecommitdiff
path: root/public/vendor/codemirror/keymap/vim.js
diff options
context:
space:
mode:
authorWu Cheng-Han2016-01-17 14:28:04 -0600
committerWu Cheng-Han2016-01-17 14:28:04 -0600
commiteaa8ccaccb1091820d0a8d1223996a6dd057347d (patch)
tree6b4aaa3b3d1a2fed68147510142663222533775a /public/vendor/codemirror/keymap/vim.js
parentce65e58096d57ace02723d11a125673f9d48c293 (diff)
Upgrade CodeMirror to 5.10.1 and now support fullscreen, jump-to-line in editor
Diffstat (limited to 'public/vendor/codemirror/keymap/vim.js')
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/keymap/vim.js35
1 files changed, 18 insertions, 17 deletions
diff --git a/public/vendor/codemirror/keymap/vim.js b/public/vendor/codemirror/keymap/vim.js
index d50cc4af..0548b75b 100755..100644
--- a/public/vendor/codemirror/keymap/vim.js
+++ b/public/vendor/codemirror/keymap/vim.js
@@ -292,12 +292,7 @@
// Keypress character binding of format "'a'"
return key.charAt(1);
}
- var pieces = key.split('-');
- if (/-$/.test(key)) {
- // If the - key was typed, split will result in 2 extra empty strings
- // in the array. Replace them with 1 '-'.
- pieces.splice(-2, 2, '-');
- }
+ var pieces = key.split(/-(?!$)/);
var lastPiece = pieces[pieces.length - 1];
if (pieces.length == 1 && pieces[0].length == 1) {
// No-modifier bindings use literal character bindings above. Skip.
@@ -1959,13 +1954,21 @@
text = text.slice(0, - match[0].length);
}
}
- var wasLastLine = head.line - 1 == cm.lastLine();
- cm.replaceRange('', anchor, head);
- if (args.linewise && !wasLastLine) {
+ var prevLineEnd = new Pos(anchor.line - 1, Number.MAX_VALUE);
+ var wasLastLine = cm.firstLine() == cm.lastLine();
+ if (head.line > cm.lastLine() && args.linewise && !wasLastLine) {
+ cm.replaceRange('', prevLineEnd, head);
+ } else {
+ cm.replaceRange('', anchor, head);
+ }
+ if (args.linewise) {
// Push the next line back down, if there is a next line.
- CodeMirror.commands.newlineAndIndent(cm);
- // null ch so setCursor moves to end of line.
- anchor.ch = null;
+ if (!wasLastLine) {
+ cm.setCursor(prevLineEnd);
+ CodeMirror.commands.newlineAndIndent(cm);
+ }
+ // make sure cursor ends up at the end of the line.
+ anchor.ch = Number.MAX_VALUE;
}
finalHead = anchor;
} else {
@@ -2144,9 +2147,7 @@
switch (actionArgs.position) {
case 'center': y = y - (height / 2) + lineHeight;
break;
- case 'bottom': y = y - height + lineHeight*1.4;
- break;
- case 'top': y = y + lineHeight*0.4;
+ case 'bottom': y = y - height + lineHeight;
break;
}
cm.scrollTo(null, y);
@@ -3208,7 +3209,7 @@
return cur;
}
- /*
+ /**
* Returns the boundaries of the next word. If the cursor in the middle of
* the word, then returns the boundaries of the current word, starting at
* the cursor. If the cursor is at the start/end of a word, and we are going
@@ -4308,7 +4309,7 @@
if (decimal + hex + octal > 1) { return 'Invalid arguments'; }
number = decimal && 'decimal' || hex && 'hex' || octal && 'octal';
}
- if (args.eatSpace() && args.match(/\/.*\//)) { 'patterns not supported'; }
+ if (args.match(/\/.*\//)) { return 'patterns not supported'; }
}
}
var err = parseArgs();