|
1129 | 1129 | cm.setSelection(curStart, curEnd); |
1130 | 1130 | } |
1131 | 1131 | } else { |
| 1132 | + curStart = cm.getCursor('anchor'); |
| 1133 | + curEnd = cm.getCursor('head'); |
1132 | 1134 | if (!vim.visualLine && actionArgs.linewise) { |
1133 | 1135 | // Shift-V pressed in characterwise visual mode. Switch to linewise |
1134 | 1136 | // visual mode instead of exiting visual mode. |
1135 | 1137 | vim.visualLine = true; |
1136 | | - curStart = cm.getCursor('anchor'); |
1137 | | - curEnd = cm.getCursor('head'); |
1138 | 1138 | curStart.ch = cursorIsBefore(curStart, curEnd) ? 0 : |
1139 | 1139 | lineLength(cm, curStart.line); |
1140 | 1140 | curEnd.ch = cursorIsBefore(curStart, curEnd) ? |
1141 | 1141 | lineLength(cm, curEnd.line) : 0; |
1142 | 1142 | 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; |
1143 | 1147 | } else { |
1144 | 1148 | exitVisualMode(cm, vim); |
1145 | 1149 | } |
|
2049 | 2053 | { name: 'redo', shortName: 'red', type: 'builtIn' }, |
2050 | 2054 | { name: 'substitute', shortName: 's', type: 'builtIn'} |
2051 | 2055 | ]; |
2052 | | - var ExCommandDispatcher = function() { |
| 2056 | + Vim.ExCommandDispatcher = function() { |
2053 | 2057 | this.buildCommandMap_(); |
2054 | 2058 | }; |
2055 | | - ExCommandDispatcher.prototype = { |
| 2059 | + Vim.ExCommandDispatcher.prototype = { |
2056 | 2060 | processCommand: function(cm, input) { |
2057 | 2061 | var inputStream = new CodeMirror.StringStream(input); |
2058 | 2062 | var params = {}; |
|
2101 | 2105 | result.lineEnd = cm.lineCount() - 1; |
2102 | 2106 | } else { |
2103 | 2107 | result.line = this.parseLineSpec_(cm, inputStream); |
2104 | | - if (result.line && inputStream.eat(',')) { |
| 2108 | + if (result.line !== undefined && inputStream.eat(',')) { |
2105 | 2109 | result.lineEnd = this.parseLineSpec_(cm, inputStream); |
2106 | 2110 | } |
2107 | 2111 | } |
|
2176 | 2180 | } |
2177 | 2181 | }, |
2178 | 2182 | map: function(lhs, rhs) { |
2179 | | - if (lhs.charAt(0) == ':') { |
| 2183 | + if (lhs != ':' && lhs.charAt(0) == ':') { |
2180 | 2184 | var commandName = lhs.substring(1); |
2181 | 2185 | if (rhs != ':' && rhs.charAt(0) == ':') { |
2182 | 2186 | // Ex to Ex mapping |
|
2329 | 2333 | } |
2330 | 2334 | }; |
2331 | 2335 |
|
2332 | | - var exCommandDispatcher = new ExCommandDispatcher(); |
| 2336 | + var exCommandDispatcher = new Vim.ExCommandDispatcher(); |
2333 | 2337 |
|
2334 | 2338 | // Register Vim with CodeMirror |
2335 | 2339 | function buildVimKeyMap() { |
|
0 commit comments