( h: Highlight, theme: Theme, maxDigits: number, fullDim: boolean, )
| 724 | } |
| 725 | |
| 726 | function addLineNumber( |
| 727 | h: Highlight, |
| 728 | theme: Theme, |
| 729 | maxDigits: number, |
| 730 | fullDim: boolean, |
| 731 | ): void { |
| 732 | const style: Style = { |
| 733 | foreground: h.marker ? decorationColor(h.marker, theme) : theme.foreground, |
| 734 | background: h.marker ? lineBackground(h.marker, theme) : theme.background, |
| 735 | } |
| 736 | const shouldDim = h.marker === null || h.marker === ' ' |
| 737 | for (let i = 0; i < h.lines.length; i++) { |
| 738 | const prefix = |
| 739 | i === 0 |
| 740 | ? ` ${String(h.lineNumber).padStart(maxDigits)} ` |
| 741 | : ' '.repeat(maxDigits + 2) |
| 742 | const wrapped = shouldDim && !fullDim ? `${DIM}${prefix}${UNDIM}` : prefix |
| 743 | h.lines[i]!.unshift([style, wrapped]) |
| 744 | } |
| 745 | } |
| 746 | |
| 747 | function addMarker(h: Highlight, theme: Theme): void { |
| 748 | if (!h.marker) return |
no test coverage detected