| 1320 | // Edit tests - configureCm is an optional argument that gives caller |
| 1321 | // access to the cm object. |
| 1322 | function testEdit(name, before, pos, edit, after, configureCm) { |
| 1323 | return testVim(name, function(cm, vim, helpers) { |
| 1324 | if (configureCm) { |
| 1325 | configureCm(cm); |
| 1326 | } |
| 1327 | var ch = before.search(pos) |
| 1328 | var line = before.substring(0, ch).split('\n').length - 1; |
| 1329 | if (line) { |
| 1330 | ch = before.substring(0, ch).split('\n').pop().length; |
| 1331 | } |
| 1332 | cm.setCursor(line, ch); |
| 1333 | helpers.doKeys.apply(this, edit.split('')); |
| 1334 | eq(after, cm.getValue()); |
| 1335 | }, {value: before}); |
| 1336 | } |
| 1337 | |
| 1338 | // These Delete tests effectively cover word-wise Change, Visual & Yank. |
| 1339 | // Tabs are used as differentiated whitespace to catch edge cases. |