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

Function moveOnce

lib/web/CodeMirror/src/edit/methods.js:479–500  ·  view source on GitHub ↗
(boundToLine)

Source from the content-addressed store, hash-verified

477 return lineObj = getLine(doc, l)
478 }
479 function moveOnce(boundToLine) {
480 let next
481 if (unit == "codepoint") {
482 let ch = lineObj.text.charCodeAt(pos.ch + (unit > 0 ? 0 : -1))
483 if (isNaN(ch)) next = null
484 else next = new Pos(pos.line, Math.max(0, Math.min(lineObj.text.length, pos.ch + dir * (ch >= 0xD800 && ch < 0xDC00 ? 2 : 1))),
485 -dir)
486 } else if (visually) {
487 next = moveVisually(doc.cm, lineObj, pos, dir)
488 } else {
489 next = moveLogically(lineObj, pos, dir)
490 }
491 if (next == null) {
492 if (!boundToLine && findNextLine())
493 pos = endOfLine(visually, doc.cm, lineObj, pos.line, lineDir)
494 else
495 return false
496 } else {
497 pos = next
498 }
499 return true
500 }
501
502 if (unit == "char" || unit == "codepoint") {
503 moveOnce()

Callers 1

findPosHFunction · 0.70

Calls 7

moveVisuallyFunction · 0.90
moveLogicallyFunction · 0.90
endOfLineFunction · 0.90
isNaNFunction · 0.85
findNextLineFunction · 0.70
maxMethod · 0.45
minMethod · 0.45

Tested by

no test coverage detected