MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / testVim

Function testVim

lib/web/CodeMirror/test/vim_test.js:127–240  ·  view source on GitHub ↗
(name, run, opts, expectedFail)

Source from the content-addressed store, hash-verified

125}
126
127function testVim(name, run, opts, expectedFail) {
128 var vimOpts = {
129 lineNumbers: true,
130 vimMode: true,
131 showCursorWhenSelecting: true,
132 value: code
133 };
134 for (var prop in opts) {
135 if (opts.hasOwnProperty(prop)) {
136 vimOpts[prop] = opts[prop];
137 }
138 }
139 return test('vim_' + name, function() {
140 var place = document.getElementById("testground");
141 var cm = CodeMirror(place, vimOpts);
142 var vim = CodeMirror.Vim.maybeInitVimState_(cm);
143
144 function doKeysFn(cm) {
145 return function(args) {
146 if (args instanceof Array) {
147 arguments = args;
148 }
149 for (var i = 0; i < arguments.length; i++) {
150 var result = CodeMirror.Vim.handleKey(cm, arguments[i]);
151 if (!result && cm.state.vim.insertMode) {
152 cm.replaceSelections(fillArray(arguments[i], cm.listSelections().length));
153 }
154 }
155 }
156 }
157 function doInsertModeKeysFn(cm) {
158 return function(args) {
159 if (args instanceof Array) { arguments = args; }
160 function executeHandler(handler) {
161 if (typeof handler == 'string') {
162 CodeMirror.commands[handler](cm);
163 } else {
164 handler(cm);
165 }
166 return true;
167 }
168 for (var i = 0; i < arguments.length; i++) {
169 var key = arguments[i];
170 // Find key in keymap and handle.
171 var handled = CodeMirror.lookupKey(key, cm.getOption('keyMap'), executeHandler, cm);
172 // Record for insert mode.
173 if (handled == "handled" && cm.state.vim.insertMode && arguments[i] != 'Esc') {
174 var lastChange = CodeMirror.Vim.getVimGlobalState_().macroModeState.lastInsertModeChanges;
175 if (lastChange && (key.indexOf('Delete') != -1 || key.indexOf('Backspace') != -1)) {
176 lastChange.changes.push(new CodeMirror.Vim.InsertModeKey(key));
177 }
178 }
179 }
180 }
181 }
182 function doExFn(cm) {
183 return function(command) {
184 cm.openDialog = helpers.fakeOpenDialog(command);

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 7

doKeysFnFunction · 0.85
doInsertModeKeysFnFunction · 0.85
doExFnFunction · 0.85
assertCursorAtFnFunction · 0.85
testFunction · 0.70
runFunction · 0.70
CodeMirrorFunction · 0.50

Tested by

no test coverage detected