MCPcopy
hub / github.com/nwutils/nw-sample-apps / skipHidden

Function skipHidden

mini-code-edit/cm/lib/codemirror.js:1215–1233  ·  view source on GitHub ↗
(pos, oldLine, oldCh)

Source from the content-addressed store, hash-verified

1213 selectionChanged = true;
1214 }
1215 function skipHidden(pos, oldLine, oldCh) {
1216 function getNonHidden(dir) {
1217 var lNo = pos.line + dir, end = dir == 1 ? doc.size : -1;
1218 while (lNo != end) {
1219 var line = getLine(lNo);
1220 if (!line.hidden) {
1221 var ch = pos.ch;
1222 if (toEnd || ch > oldCh || ch > line.text.length) ch = line.text.length;
1223 return {line: lNo, ch: ch};
1224 }
1225 lNo += dir;
1226 }
1227 }
1228 var line = getLine(pos.line);
1229 var toEnd = pos.ch == line.text.length && pos.ch != oldCh;
1230 if (!line.hidden) return pos;
1231 if (pos.line >= oldLine) return getNonHidden(1) || getNonHidden(-1);
1232 else return getNonHidden(-1) || getNonHidden(1);
1233 }
1234 function setCursor(line, ch, user) {
1235 var pos = clipPos({line: line, ch: ch || 0});
1236 (user ? setSelectionUser : setSelection)(pos, pos);

Callers 2

setSelectionFunction · 0.85
setLineHiddenFunction · 0.85

Calls 2

getLineFunction · 0.85
getNonHiddenFunction · 0.85

Tested by

no test coverage detected