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

Function findNext

lib/web/CodeMirror/keymap/vim.js:4419–4439  ·  view source on GitHub ↗
(cm, prev, query, repeat)

Source from the content-addressed store, hash-verified

4417 }, 50);
4418 }
4419 function findNext(cm, prev, query, repeat) {
4420 if (repeat === undefined) { repeat = 1; }
4421 return cm.operation(function() {
4422 var pos = cm.getCursor();
4423 var cursor = cm.getSearchCursor(query, pos);
4424 for (var i = 0; i < repeat; i++) {
4425 var found = cursor.find(prev);
4426 if (i == 0 && found && cursorEqual(cursor.from(), pos)) { found = cursor.find(prev); }
4427 if (!found) {
4428 // SearchCursor may have returned null because it hit EOF, wrap
4429 // around and try again.
4430 cursor = cm.getSearchCursor(query,
4431 (prev) ? Pos(cm.lastLine()) : Pos(cm.firstLine(), 0) );
4432 if (!cursor.find(prev)) {
4433 return;
4434 }
4435 }
4436 }
4437 return cursor.from();
4438 });
4439 }
4440 /**
4441 * Pretty much the same as `findNext`, except for the following differences:
4442 *

Callers 2

onPromptKeyUpFunction · 0.70
VimFunction · 0.70

Calls 4

cursorEqualFunction · 0.85
fromMethod · 0.80
PosFunction · 0.50
findMethod · 0.45

Tested by

no test coverage detected