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

Function clipCursorToContent

src/codemirror.js:11966–11972  ·  view source on GitHub ↗

* Clips cursor to ensure that line is within the buffer's range * If includeLineBreak is true, then allow cur.ch == lineLength.

(cm, cur, includeLineBreak)

Source from the content-addressed store, hash-verified

11964 * If includeLineBreak is true, then allow cur.ch == lineLength.
11965 */
11966 function clipCursorToContent(cm, cur, includeLineBreak) {
11967 var line = Math.min(Math.max(cm.firstLine(), cur.line), cm.lastLine() );
11968 var maxCh = lineLength(cm, line) - 1;
11969 maxCh = (includeLineBreak) ? maxCh + 1 : maxCh;
11970 var ch = Math.min(Math.max(0, cur.ch), maxCh);
11971 return Pos(line, ch);
11972 }
11973 function copyArgs(args) {
11974 var ret = {};
11975 for (var prop in args) {

Callers 4

VimFunction · 0.85
exitVisualModeFunction · 0.85
moveToColumnFunction · 0.85
updateFakeCursorFunction · 0.85

Calls 3

lineLengthFunction · 0.85
firstLineMethod · 0.80
lastLineMethod · 0.80

Tested by

no test coverage detected