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

Function bySentence

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

Source from the content-addressed store, hash-verified

9000 }
9001
9002 function bySentence(cm, pos, dir) {
9003 var line = pos.line, ch = pos.ch;
9004 var text = cm.getLine(pos.line), sawWord = false;
9005 for (;;) {
9006 var next = text.charAt(ch + (dir < 0 ? -1 : 0));
9007 if (!next) { // End/beginning of line reached
9008 if (line == (dir < 0 ? cm.firstLine() : cm.lastLine())) return Pos(line, ch);
9009 text = cm.getLine(line + dir);
9010 if (!/\S/.test(text)) return Pos(line, ch);
9011 line += dir;
9012 ch = dir < 0 ? text.length : 0;
9013 continue;
9014 }
9015 if (sawWord && /[!?.]/.test(next)) return Pos(line, ch + (dir > 0 ? 1 : 0));
9016 if (!sawWord) sawWord = /\w/.test(next);
9017 ch += dir;
9018 }
9019 }
9020
9021 function byExpr(cm, pos, dir) {
9022 var wrap;

Callers 1

codemirror.jsFile · 0.85

Calls 4

getLineMethod · 0.80
firstLineMethod · 0.80
lastLineMethod · 0.80
testMethod · 0.45

Tested by

no test coverage detected