MCPcopy
hub / github.com/witheve/Eve / byExpr

Function byExpr

src/codemirror.js:9021–9038  ·  view source on GitHub ↗
(cm, pos, dir)

Source from the content-addressed store, hash-verified

9019 }
9020
9021 function byExpr(cm, pos, dir) {
9022 var wrap;
9023 if (cm.findMatchingBracket && (wrap = cm.findMatchingBracket(pos, true))
9024 && wrap.match && (wrap.forward ? 1 : -1) == dir)
9025 return dir > 0 ? Pos(wrap.to.line, wrap.to.ch + 1) : wrap.to;
9026
9027 for (var first = true;; first = false) {
9028 var token = cm.getTokenAt(pos);
9029 var after = Pos(pos.line, dir < 0 ? token.start : token.end);
9030 if (first && dir > 0 && token.end == pos.ch || !/\w/.test(token.string)) {
9031 var newPos = cm.findPosH(after, dir, "char");
9032 if (posEq(after, newPos)) return pos;
9033 else pos = newPos;
9034 } else {
9035 return after;
9036 }
9037 }
9038 }
9039
9040 // Prefixes (only crudely supported)
9041

Callers 1

codemirror.jsFile · 0.85

Calls 4

posEqFunction · 0.85
getTokenAtMethod · 0.80
findPosHMethod · 0.80
testMethod · 0.45

Tested by

no test coverage detected