MCPcopy Create free account
hub / github.com/breck7/scroll / movePos

Function movePos

external/.scrollLibs.js:7071–7087  ·  view source on GitHub ↗
(doc, pos, dir, line)

Source from the content-addressed store, hash-verified

7069 }
7070
7071 function movePos(doc, pos, dir, line) {
7072 if (dir < 0 && pos.ch == 0) {
7073 if (pos.line > doc.first) {
7074 return clipPos(doc, Pos(pos.line - 1))
7075 } else {
7076 return null
7077 }
7078 } else if (dir > 0 && pos.ch == (line || getLine(doc, pos.line)).text.length) {
7079 if (pos.line < doc.first + doc.size - 1) {
7080 return Pos(pos.line + 1, 0)
7081 } else {
7082 return null
7083 }
7084 } else {
7085 return new Pos(pos.line, pos.ch + dir)
7086 }
7087 }
7088
7089 function selectAll(cm) {
7090 cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()), sel_dontScroll)

Callers 1

skipAtomicInnerFunction · 0.85

Calls 3

clipPosFunction · 0.85
PosFunction · 0.85
getLineFunction · 0.85

Tested by

no test coverage detected