MCPcopy
hub / github.com/ajaxorg/ace / testVim

Function testVim

src/keyboard/vim_test.js:258–330  ·  view source on GitHub ↗
(name, run, opts, expectedFail)

Source from the content-addressed store, hash-verified

256}
257
258function testVim(name, run, opts, expectedFail) {
259 var vimOpts = {
260 lineNumbers: true,
261 vimMode: true,
262 showCursorWhenSelecting: true,
263 value: code
264 };
265 for (var prop in opts) {
266 if (opts.hasOwnProperty(prop)) {
267 vimOpts[prop] = opts[prop];
268 }
269 }
270 return test('vim_' + name, async function(done) {
271 var place = document.createElement("testground"); //ace_patch
272 place.style.visibility = "visible";
273 var cm = CodeMirror(place, vimOpts);
274 var vim = CodeMirror.Vim.maybeInitVimState_(cm);
275 CodeMirror.Vim.mapclear();
276
277 cm.focus();
278 // workaround for cm5 slow polling in blurred window
279 Object.defineProperty(cm.state, "focused", {
280 set: function(e) {},
281 get: function() {
282 return document.activeElement == cm.getInputField();
283 }
284 });
285
286 var helpers = {
287 doKeys: function() {
288 var args = arguments[0]
289 if (!Array.isArray(args)) { args = arguments; }
290 for (var i = 0; i < args.length; i++) {
291 var key = args[i];
292 if (key.length > 1 && key[0] == "<" && key.slice(-1) == ">") {
293 key = vimKeyToKeyName(key.slice(1, -1));
294 }
295 typeKey(key);
296 }
297 },
298 doEx: function(command) {
299 helpers.doKeys(':', command, '\n');
300 },
301 assertCursorAt: function(line, ch) {
302 var pos;
303 if (ch == null && typeof line.line == 'number') {
304 pos = line;
305 } else {
306 pos = makeCursor(line, ch);
307 }
308 eqCursorPos(cm.getCursor(), pos);
309 },
310 getRegisterController: function() {
311 return CodeMirror.Vim.getRegisterController();
312 },
313 getNotificationText: function() {
314 var container = cm.getWrapperElement().querySelector(".cm-vim-message");
315 return container && container.textContent;

Callers 8

vim_test.jsFile · 0.85
testJumplistFunction · 0.85
testMotionFunction · 0.85
testMotionWithFoldingFunction · 0.85
testEditFunction · 0.85
testSelectionFunction · 0.85
testSubstituteFunction · 0.85
testSubstituteConfirmFunction · 0.85

Calls 11

vimKeyToKeyNameFunction · 0.85
makeCursorFunction · 0.85
eqCursorPosFunction · 0.85
sliceMethod · 0.80
getCursorMethod · 0.80
testFunction · 0.70
CodeMirrorFunction · 0.70
removeMethod · 0.65
runFunction · 0.50
doneFunction · 0.50
focusMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…