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

Function add

lib/web/CodeMirror/keymap/vim.js:549–575  ·  view source on GitHub ↗
(cm, oldCur, newCur)

Source from the content-addressed store, hash-verified

547 var tail = 0;
548 var buffer = new Array(size);
549 function add(cm, oldCur, newCur) {
550 var current = pointer % size;
551 var curMark = buffer[current];
552 function useNextSlot(cursor) {
553 var next = ++pointer % size;
554 var trashMark = buffer[next];
555 if (trashMark) {
556 trashMark.clear();
557 }
558 buffer[next] = cm.setBookmark(cursor);
559 }
560 if (curMark) {
561 var markPos = curMark.find();
562 // avoid recording redundant cursor position
563 if (markPos && !cursorEqual(markPos, oldCur)) {
564 useNextSlot(oldCur);
565 }
566 } else {
567 useNextSlot(oldCur);
568 }
569 useNextSlot(newCur);
570 head = pointer;
571 tail = pointer - size + 1;
572 if (tail < 0) {
573 tail = 0;
574 }
575 }
576 function move(cm, offset) {
577 pointer += offset;
578 if (pointer > head) {

Callers

nothing calls this directly

Calls 3

cursorEqualFunction · 0.85
useNextSlotFunction · 0.85
findMethod · 0.45

Tested by

no test coverage detected