Repository navigation
feat(editor): add an opt-in editor font family (default: follow terminal font) - #9658
Conversation
…nal font) Monaco-based editor surfaces hard-wired terminalFontFamily, so CJK users on Nerd Font "Mono" variants (single-cell advances for wide glyphs) got overlapping Hangul/CJK in the editor while the terminal stayed correct. Add an opt-in `editorFontFamily` setting that defaults to empty, resolving to the terminal font byte-identically for existing users. New surfaces resolve via `resolveEditorFontFamily`; the notebook shell keeps its inherit-UI-font fallback via `resolveEditorFontFamilyOrInherit`. Fixes #9628 Co-authored-by: Orca <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (23)
📝 WalkthroughWalkthroughAdds an optional 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…nal font) (stablyai#9658) The code editor was hard-wired to the terminal font, so Nerd Font 'Mono' CJK glyphs overlapped in the editor. Adds an opt-in editorFontFamily setting; default is empty so the resolved value is byte-identical to today for every existing user. Closes stablyai#9628
What
On Monaco-based editor surfaces (file editor, diffs, notebook cells, code excerpts) the font was hard-wired to the terminal font. Users who set their terminal font to a Nerd Font "Mono" variant saw CJK/Hangul text overlap in the editor: the
--monopatch clamps every glyph advance to a single cell, so wide glyphs (ink ~2 cells) advance only 1 cell and pile up on top of each other. The terminal itself stayed correct because it sizes cells from Unicode tables, not font advances. There was no way to give the editor its own font.Why it happened
MonacoEditor.tsx:155didconst editorFontFamily = settings?.terminalFontFamily || 'monospace'and fed it straight into Monaco (updateOptionsat:718, options at:836). The same terminal-font reuse existed inDiffViewer.tsx:425,IpynbViewer.tsx:412/:877,MonacoCodeExcerpt.tsx:54, andDiffSectionBody.tsx:194(fromDiffSectionItem.tsx:434). NoeditorFontFamilysetting existed anywhere —types.ts:2597-2618andconstants.ts:190-203declared onlyappFontFamilyandterminalFontFamily— so the editor could not be given a different font.ELI5
The code editor was borrowing the font you picked for your terminal. Some of those fonts are specially squished so every character takes exactly one column — which looks fine in a terminal but makes Chinese, Japanese, and Korean letters crash into each other in the editor. This adds a separate "editor font" setting; leave it blank and nothing changes, or set it to a normal font to fix the overlap.
Evidence
Independent metric check of the Nerd-Fonts "Mono" patch (fontTools 4.61.1, upm=1950) confirms the advance-clamping that causes the overlap:
The editor and terminal are on different rendering paths — the terminal never uses font advances:
The fix introduces a pure resolver and a new opt-in setting (default empty), plus tests. New
MonacoEditor.font-family.test.tsx(91 lines) and expandededitor-font-zoom.test.tsassert that witheditorFontFamilyunset the resolver returns the byte-identical terminal-font string, and that a set value is honoured:The notebook shell's inherit-UI-font branch (
IpynbViewer.tsx:877, previously falling back toundefinedrather thanmonospace) is preserved via a dedicatedresolveEditorFontFamilyOrInherit.Trade-offs
Zero user-visible regressions. The new
editorFontFamilysetting defaults to empty, andresolveEditorFontFamily(settings)returnseditorFontFamily?.trim() || terminalFontFamily || 'monospace'— the identical string as before for anyone who does not set it. Per the repro's risk notes, the fix deliberately does not route the editor throughbuildFontFamily()(which would append the Nerd-Font/PUA fallback chain and change glyph rendering for every existing user), and preserves the notebook inherit-font branch.Perf
Review
Reviewed by an independent agent for 1 round — final verdict: CLEAN.
Closes #9628
Made with Orca 🐋