Making the whitespaces align vertically with variable font text#298252
Making the whitespaces align vertically with variable font text#298252
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adjusts editor whitespace rendering so that whitespace markers are rendered via the experimental whitespace overlay even on lines that contain variable-font-affecting decorations, improving alignment with the actual rendered text.
Changes:
- Enable
WhitespaceOverlayrendering for lines flagged withlineData.hasVariableFonts(remove the early-return skip). - Ensure view-line DOM rendering does not render whitespace when
experimentalWhitespaceRendering !== 'off', regardless ofhasVariableFonts, so the overlay is the single whitespace-rendering mechanism in experimental modes.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/vs/editor/browser/viewParts/whitespace/whitespace.ts |
Removes the variable-font short-circuit so the overlay can render whitespace markers on those lines. |
src/vs/editor/browser/viewParts/viewLines/viewLine.ts |
Simplifies the whitespace rendering decision so experimental modes always delegate whitespace rendering to the overlay. |
| this._options = new WhitespaceOptions(this._context.configuration); | ||
| this._selection = []; | ||
| this._renderResult = null; | ||
| this._fontMetricsCache = new FontMetricsCache(); |
There was a problem hiding this comment.
Would we want to share this instance across multiple editor views? Otherwise it needs to be recreated every time. Come to think of it, shouldn't we simply enhance FontInfo to contain also these two properties -- ascent and descent?
There is a lot of infrastructure in place to store that across editors, to reset the cache when the DPI changes (like plugging in a monitor or moving the window to another monitor), as well as to cache the values across vscode restarts to avoid flickering or slowness on startup.
This is all implemented at
and I think you should be able to enhance it to add these extra props?
fixes #298249