MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / createCodeEditorState

Function createCodeEditorState

scripts/hsr/widget-code-editor-state.mjs:58–79  ·  view source on GitHub ↗
(draft, options = {})

Source from the content-addressed store, hash-verified

56}
57
58export function createCodeEditorState(draft, options = {}) {
59 const lines = splitCodeDraft(draft);
60 const scrollTop =
61 typeof options.scrollTop === "number" && Number.isFinite(options.scrollTop)
62 ? Math.max(0, Math.floor(options.scrollTop))
63 : 0;
64 const scrollLeft =
65 typeof options.scrollLeft === "number" && Number.isFinite(options.scrollLeft)
66 ? Math.max(0, Math.floor(options.scrollLeft))
67 : 0;
68
69 const preferredCursor = options.cursor ? clampCodeCursor(lines, options.cursor) : null;
70 const cursor = preferredCursor ?? findBannerCursor(lines);
71
72 return Object.freeze({
73 lines,
74 cursor,
75 selection: null,
76 scrollTop,
77 scrollLeft,
78 });
79}

Callers 3

widget-app.mjsFile · 0.90
saveBannerToWidgetFileFunction · 0.90

Calls 3

splitCodeDraftFunction · 0.85
clampCodeCursorFunction · 0.85
findBannerCursorFunction · 0.85

Tested by

no test coverage detected