MCPcopy Index your code
hub / github.com/codeaashu/claude-code / buildCharToSegmentMap

Function buildCharToSegmentMap

src/ink/render-node-to-output.ts:192–201  ·  view source on GitHub ↗

* Build a mapping from each character position in the plain text to its segment index. * Returns an array where charToSegment[i] is the segment index for character i.

(segments: StyledSegment[])

Source from the content-addressed store, hash-verified

190 * Returns an array where charToSegment[i] is the segment index for character i.
191 */
192function buildCharToSegmentMap(segments: StyledSegment[]): number[] {
193 const map: number[] = []
194 for (let i = 0; i < segments.length; i++) {
195 const len = segments[i]!.text.length
196 for (let j = 0; j < len; j++) {
197 map.push(i)
198 }
199 }
200 return map
201}
202
203/**
204 * Apply styles to wrapped text by mapping each character back to its original segment.

Callers 1

renderNodeToOutputFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected