(prepared: PreparedTextWithSegments, maxWidth: number, lineHeight: number)
| 878 | // decisions, but keeps extra per-line bookkeeping so it should stay off the |
| 879 | // resize hot path. |
| 880 | export function layoutWithLines(prepared: PreparedTextWithSegments, maxWidth: number, lineHeight: number): LayoutLinesResult { |
| 881 | const lines: LayoutLine[] = [] |
| 882 | if (prepared.widths.length === 0) return { lineCount: 0, height: 0, lines } |
| 883 | |
| 884 | const graphemeCache = getLineTextCache(prepared) |
| 885 | const lineCount = walkPreparedLinesRaw( |
| 886 | getInternalPrepared(prepared), |
| 887 | maxWidth, |
| 888 | (width, startSegmentIndex, startGraphemeIndex, endSegmentIndex, endGraphemeIndex) => { |
| 889 | lines.push(createLayoutLine( |
| 890 | prepared, |
| 891 | graphemeCache, |
| 892 | width, |
| 893 | startSegmentIndex, |
| 894 | startGraphemeIndex, |
| 895 | endSegmentIndex, |
| 896 | endGraphemeIndex, |
| 897 | )) |
| 898 | }, |
| 899 | ) |
| 900 | |
| 901 | return { lineCount, height: lineCount * lineHeight, lines } |
| 902 | } |
| 903 | |
| 904 | export function clearCache(): void { |
| 905 | clearAnalysisCaches() |
no test coverage detected
searching dependent graphs…