MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / clipCursorToContent

Function clipCursorToContent

static/js/codemirror/keymap/vim.js:1400–1406  ·  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

1398 * If includeLineBreak is true, then allow cur.ch == lineLength.
1399 */
1400 function clipCursorToContent(cm, cur, includeLineBreak) {
1401 var line = Math.min(Math.max(cm.firstLine(), cur.line), cm.lastLine() );
1402 var maxCh = lineLength(cm, line) - 1;
1403 maxCh = (includeLineBreak) ? maxCh + 1 : maxCh;
1404 var ch = Math.min(Math.max(0, cur.ch), maxCh);
1405 return { line: line, ch: ch };
1406 }
1407 // Merge arguments in place, for overriding arguments.
1408 function mergeArgs(to, from) {
1409 for (var prop in from) {

Callers 3

VimFunction · 0.85
exitVisualModeFunction · 0.85
moveToColumnFunction · 0.85

Calls 1

lineLengthFunction · 0.70

Tested by

no test coverage detected