MCPcopy Create free account
hub / github.com/anomalyco/opencode / offsetToPosition

Function offsetToPosition

packages/tui/src/editor-zed.ts:223–226  ·  view source on GitHub ↗
(text: string, offset: number)

Source from the content-addressed store, hash-verified

221}
222
223export function offsetToPosition(text: string, offset: number) {
224 const stringOffset = utf8ByteOffsetToStringIndex(text, offset)
225 return offsetsToSelection(text, stringOffset, stringOffset).start
226}
227
228function utf8ByteOffsetToStringIndex(text: string, byteOffset: number) {
229 if (byteOffset <= 0) return 0

Callers 1

Calls 2

offsetsToSelectionFunction · 0.85

Tested by

no test coverage detected