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