Skip to content

Commit 15d03e1

Browse files
mightyguavamarijnh
authored andcommitted
[vim keymap] Catch up on unit tests
1 parent b92b5a5 commit 15d03e1

File tree

2 files changed

+202
-54
lines changed

2 files changed

+202
-54
lines changed

keymap/vim.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,17 +1129,21 @@
11291129
cm.setSelection(curStart, curEnd);
11301130
}
11311131
} else {
1132+
curStart = cm.getCursor('anchor');
1133+
curEnd = cm.getCursor('head');
11321134
if (!vim.visualLine && actionArgs.linewise) {
11331135
// Shift-V pressed in characterwise visual mode. Switch to linewise
11341136
// visual mode instead of exiting visual mode.
11351137
vim.visualLine = true;
1136-
curStart = cm.getCursor('anchor');
1137-
curEnd = cm.getCursor('head');
11381138
curStart.ch = cursorIsBefore(curStart, curEnd) ? 0 :
11391139
lineLength(cm, curStart.line);
11401140
curEnd.ch = cursorIsBefore(curStart, curEnd) ?
11411141
lineLength(cm, curEnd.line) : 0;
11421142
cm.setSelection(curStart, curEnd);
1143+
} else if (vim.visualLine && !actionArgs.linewise) {
1144+
// v pressed in linewise visual mode. Switch to characterwise visual
1145+
// mode instead of exiting visual mode.
1146+
vim.visualLine = false;
11431147
} else {
11441148
exitVisualMode(cm, vim);
11451149
}
@@ -2049,10 +2053,10 @@
20492053
{ name: 'redo', shortName: 'red', type: 'builtIn' },
20502054
{ name: 'substitute', shortName: 's', type: 'builtIn'}
20512055
];
2052-
var ExCommandDispatcher = function() {
2056+
Vim.ExCommandDispatcher = function() {
20532057
this.buildCommandMap_();
20542058
};
2055-
ExCommandDispatcher.prototype = {
2059+
Vim.ExCommandDispatcher.prototype = {
20562060
processCommand: function(cm, input) {
20572061
var inputStream = new CodeMirror.StringStream(input);
20582062
var params = {};
@@ -2101,7 +2105,7 @@
21012105
result.lineEnd = cm.lineCount() - 1;
21022106
} else {
21032107
result.line = this.parseLineSpec_(cm, inputStream);
2104-
if (result.line && inputStream.eat(',')) {
2108+
if (result.line !== undefined && inputStream.eat(',')) {
21052109
result.lineEnd = this.parseLineSpec_(cm, inputStream);
21062110
}
21072111
}
@@ -2176,7 +2180,7 @@
21762180
}
21772181
},
21782182
map: function(lhs, rhs) {
2179-
if (lhs.charAt(0) == ':') {
2183+
if (lhs != ':' && lhs.charAt(0) == ':') {
21802184
var commandName = lhs.substring(1);
21812185
if (rhs != ':' && rhs.charAt(0) == ':') {
21822186
// Ex to Ex mapping
@@ -2329,7 +2333,7 @@
23292333
}
23302334
};
23312335

2332-
var exCommandDispatcher = new ExCommandDispatcher();
2336+
var exCommandDispatcher = new Vim.ExCommandDispatcher();
23332337

23342338
// Register Vim with CodeMirror
23352339
function buildVimKeyMap() {

0 commit comments

Comments
 (0)