MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / clipCursorToContent

Function clipCursorToContent

lib/web/CodeMirror/keymap/vim.js:2916–2923  ·  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)

Source from the content-addressed store, hash-verified

2914 * If includeLineBreak is true, then allow cur.ch == lineLength.
2915 */
2916 function clipCursorToContent(cm, cur) {
2917 var vim = cm.state.vim;
2918 var includeLineBreak = vim.insertMode || vim.visualMode;
2919 var line = Math.min(Math.max(cm.firstLine(), cur.line), cm.lastLine() );
2920 var maxCh = lineLength(cm, line) - 1 + !!includeLineBreak;
2921 var ch = Math.min(Math.max(0, cur.ch), maxCh);
2922 return Pos(line, ch);
2923 }
2924 function copyArgs(args) {
2925 var ret = {};
2926 for (var prop in args) {

Callers 4

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

Calls 4

lineLengthFunction · 0.70
PosFunction · 0.50
minMethod · 0.45
maxMethod · 0.45

Tested by

no test coverage detected