Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions scripts/browser-check.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,17 @@ async function checkEditorNewlines(page) {
`${name}: retained after switching languages`,
);
}

// The overlay paints the glyphs the textarea positions, so a <code> that
// resolves its own font family drifts away from the caret line by line.
assert.equal(
await page
.locator("#editor-highlight code")
.evaluate((node) => getComputedStyle(node).fontFamily),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up on my suggestion in #199: I meant the computed font styles as a whole, not only the family. The commit message says the drift came from the taller line box, so fontSize and lineHeight belong in the comparison too; otherwise a later font-size on <code> brings the drift back with this check still green. For example:

const metrics = (node) => {
  const s = getComputedStyle(node);
  return [s.fontFamily, s.fontSize, s.lineHeight, s.letterSpacing];
};

await editor.evaluate((node) => getComputedStyle(node).fontFamily),
"editor: highlight font matches the textarea",
);

console.log(
`editor: ${cases.length} Enter cases passed, including undo, redo and language switching`,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check has nothing to do with Enter handling, but it sits in checkEditorNewlines, and this log line still only reports the Enter cases. Could you either move it into its own small function (e.g. checkEditorOverlayFont), or extend the message so a passing run shows the font check ran?

);
Expand Down
4 changes: 4 additions & 0 deletions web/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,10 @@ p {
overflow: hidden;
}

#editor-highlight code {
font: inherit;
}

#editor-lines {
position: absolute;
inset: 0 auto 0 0;
Expand Down