(themeName: string, width: number, dim: boolean)
| 858 | } |
| 859 | |
| 860 | render(themeName: string, width: number, dim: boolean): string[] | null { |
| 861 | const mode = detectColorMode(themeName) |
| 862 | const theme = buildTheme(themeName, mode) |
| 863 | const lang = detectLanguage(this.filePath, this.firstLine) |
| 864 | const hlState = { lang, stack: null } |
| 865 | |
| 866 | // Warm highlighter with prefix lines (highlight.js is stateless per call, |
| 867 | // so this is a no-op for now — preserved for API parity) |
| 868 | void this.prefixContent |
| 869 | |
| 870 | const maxDigits = String(maxLineNumber(this.hunk)).length |
| 871 | let oldLine = this.hunk.oldStart |
| 872 | let newLine = this.hunk.newStart |
| 873 | const effectiveWidth = Math.max(1, width - maxDigits - 2 - 1) |
| 874 | |
| 875 | // First pass: assign markers + line numbers |
| 876 | type Entry = { lineNumber: number; marker: Marker; code: string } |
| 877 | const entries: Entry[] = this.hunk.lines.map(rawLine => { |
| 878 | const marker = parseMarker(rawLine.slice(0, 1)) |
| 879 | const code = rawLine.slice(1) |
| 880 | let lineNumber: number |
| 881 | switch (marker) { |
| 882 | case '+': |
| 883 | lineNumber = newLine++ |
| 884 | break |
| 885 | case '-': |
| 886 | lineNumber = oldLine++ |
| 887 | break |
| 888 | case ' ': |
| 889 | lineNumber = newLine |
| 890 | oldLine++ |
| 891 | newLine++ |
| 892 | break |
| 893 | } |
| 894 | return { lineNumber, marker, code } |
| 895 | }) |
| 896 | |
| 897 | // Word-diff ranges (skip when dim — too loud) |
| 898 | const ranges: Range[][] = entries.map(() => []) |
| 899 | if (!dim) { |
| 900 | const markers = entries.map(e => e.marker) |
| 901 | for (const [delIdx, addIdx] of findAdjacentPairs(markers)) { |
| 902 | const [delR, addR] = wordDiffStrings( |
| 903 | entries[delIdx]!.code, |
| 904 | entries[addIdx]!.code, |
| 905 | ) |
| 906 | ranges[delIdx] = delR |
| 907 | ranges[addIdx] = addR |
| 908 | } |
| 909 | } |
| 910 | |
| 911 | // Second pass: highlight + transform pipeline |
| 912 | const out: string[] = [] |
| 913 | for (let i = 0; i < entries.length; i++) { |
| 914 | const { lineNumber, marker, code } = entries[i]! |
| 915 | const tokens: Block[] = |
| 916 | marker === '-' |
| 917 | ? [[defaultStyle(theme), code]] |
nothing calls this directly
no test coverage detected