* 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[])
| 193 | * Returns an array where charToSegment[i] is the segment index for character i. |
| 194 | */ |
| 195 | function buildCharToSegmentMap(segments: StyledSegment[]): number[] { |
| 196 | const map: number[] = [] |
| 197 | for (let i = 0; i < segments.length; i++) { |
| 198 | const len = segments[i]!.text.length |
| 199 | for (let j = 0; j < len; j++) { |
| 200 | map.push(i) |
| 201 | } |
| 202 | } |
| 203 | return map |
| 204 | } |
| 205 | |
| 206 | /** |
| 207 | * Apply styles to wrapped text by mapping each character back to its original segment. |
no outgoing calls
no test coverage detected