Conversation
There was a problem hiding this comment.
A few notes on the description and commit message:
-
The commit message says "On macOS that is a different font from the textarea's ui-monospace". As far as I know, only Safari resolves
ui-monospace; Chrome and Firefox skip it and use a later entry in the stack. That would explain why #82 saw no drift in Chrome on the same Mac, so "Safari on macOS" would be more precise. -
In #82, jserv asked whether the drift persists while typing or is temporary and goes away after a new session, as in #155. A font mismatch should show up from the first keystroke and should not go away on its own. Could you say in the description which one you saw? If #155's case isn't explained by this change,
Refs #82may fit better thanCloses #82for now, or note that the temporary case is still open.
The <code> element inside #editor-highlight took font-family: monospace from the user-agent stylesheet instead of the stack set on the overlay. Safari on macOS resolves the textarea's ui-monospace to SF Mono, so the two layers used different fonts, and the taller line box moved the painted text away from the caret a little more on every line. Other browsers skip ui-monospace and can land on the same font for both.
c962454 to
0fb42c3
Compare
|
The commit message now says Safari on macOS, since Chrome and Firefox skip ui-monospace. The drift I saw was there from the first lines I typed, grew with the line count, and did not go away after starting a new session. A font mismatch cannot explain a drift that clears on its own as in #155, so the description now says Refs #82 instead of Closes #82. The check moved to tests/browser/editor-pipeline.test.js and compares fontFamily, fontSize, lineHeight, fontWeight and letterSpacing of #editor and #editor-highlight code; the browser-check.cjs change is dropped. On main it fails on fontFamily (monospace against the ui-monospace stack), it passes with the fix, and adding a font-size to #editor-highlight code makes it fail again. One correction: the offline lane does run in CI, as the browser_check_accepts_running_rust_server_offline_interview step in check.yml, though not under scripts/test.sh. |
Makes the highlight overlay inherit the editor font so the caret stays aligned in Safari on macOS, and adds a browser test that compares the font metrics of the overlay with the textarea's.
Tested on macOS 27.0 with Safari 27.0 (22625.1.29.11.27). The drift was there from the first lines I typed, grew with the line count, and did not go away after starting a new session. After running
document.querySelector("#editor-highlight code").style.font = "inherit"in the developer console, the caret stayed aligned with the text on every line.Refs #82
Summary by cubic
Fixes the highlight overlay caret drifting away from the text on macOS by making the overlay inherit the editor font instead of the user-agent monospace.
Refs #82.
Written for commit 0fb42c3. Summary will update on new commits.