MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / isCursorVisible

Function isCursorVisible

src/lib/editorManager.js:2492–2503  ·  view source on GitHub ↗

* Checks if the cursor is visible within the CodeMirror viewport. * @returns {boolean} - True if the cursor is visible, false otherwise.

()

Source from the content-addressed store, hash-verified

2490 * @returns {boolean} - True if the cursor is visible, false otherwise.
2491 */
2492 function isCursorVisible() {
2493 const view = editor;
2494 const scroller = view?.scrollDOM;
2495 if (!view || !scroller) return true;
2496
2497 const { head } = view.state.selection.main;
2498 const caret = safeCoordsAtPos(view, head);
2499 if (!caret) return true;
2500
2501 const scrollerRect = scroller.getBoundingClientRect();
2502 return caret.top >= scrollerRect.top && caret.bottom <= scrollerRect.bottom;
2503 }
2504
2505 function safeCoordsAtPos(view, pos) {
2506 try {

Callers 1

EditorManagerFunction · 0.85

Calls 1

safeCoordsAtPosFunction · 0.85

Tested by

no test coverage detected