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

Function normalizeInputCursor

packages/core/src/runtime/inputEditor.ts:209–223  ·  view source on GitHub ↗
(value: string, cursor: number)

Source from the content-addressed store, hash-verified

207 * Clamps to [0, value.length] and snaps to the previous boundary.
208 */
209export function normalizeInputCursor(value: string, cursor: number): number {
210 const c = clampInputCursor(value, cursor);
211 if (c === 0 || c === value.length) return c;
212
213 let off = 0;
214 let last = 0;
215 while (off < value.length) {
216 const end = nextClusterEnd(value, off);
217 if (end === c) return c;
218 if (end > c) return last;
219 last = end;
220 off = end;
221 }
222 return value.length;
223}
224
225function normalizeInputCursorForward(value: string, cursor: number): number {
226 const c = clampInputCursor(value, cursor);

Callers 9

submitFrameMethod · 0.85
readInputSnapshotFunction · 0.85
routeInputEditingEventFunction · 0.85
normalizeInputSelectionFunction · 0.85
moveCursorToLineEdgeFunction · 0.85
moveCursorVerticalFunction · 0.85
applyInputEditEventFunction · 0.85
assertInvariantsFunction · 0.85

Calls 2

clampInputCursorFunction · 0.85
nextClusterEndFunction · 0.85

Tested by 1

assertInvariantsFunction · 0.68