(highlights: TextHighlight[])
| 74 | } |
| 75 | |
| 76 | segment(highlights: TextHighlight[]): TextSegment[] { |
| 77 | const segments: TextSegment[] = [] |
| 78 | |
| 79 | for (const highlight of highlights) { |
| 80 | const before = this.segmentTo(highlight.start) |
| 81 | if (before) segments.push(before) |
| 82 | |
| 83 | const highlighted = this.segmentTo(highlight.end) |
| 84 | if (highlighted) { |
| 85 | highlighted.highlight = highlight |
| 86 | segments.push(highlighted) |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | const after = this.segmentTo(Infinity) |
| 91 | if (after) segments.push(after) |
| 92 | |
| 93 | return segments |
| 94 | } |
| 95 | |
| 96 | private segmentTo(targetVisiblePos: number): TextSegment | null { |
| 97 | if ( |
no test coverage detected