fix: add terminal font fallbacks#2150
Conversation
|
fixes #2142 |
Greptile SummaryThis PR introduces
Confidence Score: 5/5Safe to merge — the change is well-scoped, fully unit-tested, and correctly handles all the CSS font-family edge cases that were flagged in earlier review threads. The new font utility correctly splits comma-separated font lists (respecting quoted substrings), quotes individual names, escapes embedded double-quotes, deduplicates against the fallback list, and handles CSS generic families. All three call sites in pty.ts and use-pty.ts are updated consistently. The unit tests cover the full range of inputs including pre-quoted CSS lists, embedded quotes, generic families, and the no-argument path. No regressions were found on the changed code paths. No files require special attention.
|
| Filename | Overview |
|---|---|
| src/renderer/lib/pty/terminal-font.ts | New module implementing CSS-aware font-family quoting, comma-aware splitting (respecting quoted substrings), and fallback appending. Logic and edge cases are correctly handled; all test cases verify correctly. |
| src/renderer/lib/pty/terminal-font.test.ts | Comprehensive unit tests covering spaces, embedded quotes, comma-separated lists, pre-quoted CSS lists, generic families, and the no-argument fallback path. |
| src/renderer/lib/pty/pty.ts | Adds buildTerminalFontFamily() to the initial xterm Terminal options so the fallback stack is active from construction, before any user settings are loaded. |
| src/renderer/lib/pty/use-pty.ts | Both the settings-load path and the runtime font-change event path now route through buildTerminalFontFamily, ensuring fallbacks are always appended and font names are properly quoted. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[fontFamily string from user setting or event] --> B[buildTerminalFontFamily]
B --> C{fontFamily provided?}
C -- No --> D[TERMINAL_FONT_FALLBACKS only]
C -- Yes --> E[splitFontFamilies]
E --> F[Quote-aware comma split]
F --> G[userFonts concat TERMINAL_FONT_FALLBACKS]
D --> H[map quoteFontFamily over each name]
G --> H
H --> I{CSS generic family?}
I -- Yes --> J[Return unquoted]
I -- No --> K[Already quoted by regex?]
K -- Yes --> L[Return as-is]
K -- No --> M[Escape backslash and quotes then wrap in double quotes]
J --> N[new Set deduplicate]
L --> N
M --> N
N --> O[join with comma-space]
O --> P[xterm fontFamily option]
Reviews (2): Last reviewed commit: "fix: preserve terminal font family lists" | Re-trigger Greptile
summary