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

Function updateFakeCursor

lib/web/CodeMirror/keymap/vim.js:5530–5545  ·  view source on GitHub ↗

* Keeps track of a fake cursor to support visual mode cursor behavior.

(cm)

Source from the content-addressed store, hash-verified

5528 * Keeps track of a fake cursor to support visual mode cursor behavior.
5529 */
5530 function updateFakeCursor(cm) {
5531 var className = 'cm-animate-fat-cursor';
5532 var vim = cm.state.vim;
5533 var from = clipCursorToContent(cm, copyCursor(vim.sel.head));
5534 var to = offsetCursor(from, 0, 1);
5535 clearFakeCursor(vim);
5536 // In visual mode, the cursor may be positioned over EOL.
5537 if (from.ch == cm.getLine(from.line).length) {
5538 var widget = document.createElement("span");
5539 widget.textContent = "\u00a0";
5540 widget.className = className;
5541 vim.fakeCursorBookmark = cm.setBookmark(from, {widget: widget});
5542 } else {
5543 vim.fakeCursor = cm.markText(from, to, {className: className});
5544 }
5545 }
5546 function clearFakeCursor(vim) {
5547 if (vim.fakeCursor) {
5548 vim.fakeCursor.clear();

Callers 2

updateCmSelectionFunction · 0.85
onCursorActivityFunction · 0.85

Calls 5

clipCursorToContentFunction · 0.85
clearFakeCursorFunction · 0.85
copyCursorFunction · 0.70
offsetCursorFunction · 0.70
getLineMethod · 0.65

Tested by

no test coverage detected