Fix Markdown preview monospace fallback when editor font is missing#325629
Open
cipheraxat wants to merge 2 commits into
Open
Fix Markdown preview monospace fallback when editor font is missing#325629cipheraxat wants to merge 2 commits into
cipheraxat wants to merge 2 commits into
Conversation
When editor.fontFamily names a missing font, CSS var() fallbacks never apply because the variable is still set. Append a monospace stack outside var() so preview/notebook/document code keeps a monospace cascade.
Contributor
Author
VerificationWith
Local Code OSS launch was flaky in this environment, so confirmation used a CSS-faithful preview webview repro of the same |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes Markdown preview (and related markdown renderers) so inline and fenced code reliably fall back to a monospace font even when --vscode-editor-font-family is set to a missing/invalid font name by appending a monospace stack outside var(--vscode-editor-font-family).
Changes:
- Update Markdown preview CSS to append a monospace fallback stack after
var(--vscode-editor-font-family). - Apply the same font-family fallback pattern to notebook markdown rendering CSS.
- Align workbench markdown document rendering
pre codestyling with the preview’s improved fallback behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/vs/workbench/contrib/markdown/browser/markdownDocumentRenderer.ts | Ensures rendered markdown pre code uses editor font when available but falls back to a monospace stack when it isn’t. |
| extensions/markdown-language-features/notebook/index.ts | Updates notebook markdown code styling to append a monospace stack after the editor font variable. |
| extensions/markdown-language-features/media/markdown.css | Fixes preview code font fallback by moving the monospace stack outside var(), addressing missing-font scenarios. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
codeusedfont-family: var(--vscode-editor-font-family, …monospace). CSS only uses thevar()fallback when the variable is unset; wheneditor.fontFamilynames a missing font the variable is still set, so code rendered in a proportional/serif face.var()in preview CSS, notebook markdowncode, and workbenchpre code, matching how the editor massages font families.themeing.ts) to keep blast radius preview-scoped.Fixes #324256
Test plan
"editor.fontFamily": "TotallyMissingFontName"(nomonospacein the stack).mdwith inline`code`and a fenced block; open Markdown PreviewConsolas, monospace), preview fonts look unchangedmarkdown.preview.fontFamily