Page MenuHomePhabricator

Syntax Highlighting in 2017 editor misaligned due to lack of "lang" attribute on the CodeMirror container
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

What happens?:

Screenshot 2023-07-07 192649.png (908×1 px, 117 KB)

We can see the html element with lang="zh-Hans", the VisualEditor layer (class=ve-ce-documentNode-codeEditor-webkit-hide) with lang="en", which are all good.
But the CodeMirror container doesn't have lang attribute set: <div class="CodeMirror cm-s-default CodeMirror-wrap">

As a result, the browser would choose different fonts for the VisualEditor layer and the CodeMirror layer.
In the Computed tab of the styles inspector, I can see for the VisualEditor layer the rendered font is Consolas;
and for the CodeMirror layer the font chosen is NSimSun which is for zh-hans and is inherited from the root html element.

This might be a recent regression?

What should have happened instead?:

The CodeMirror container has the lang attribute set to en, so the font chosen would be the same as the VisualEditor layer and no misalignment.

Software version (skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

May need some fonts installed for the user language on the machine to reproduce this issue, for me is zh-hans and NSimSun on Windows 10.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change 935871 had a related patch set uploaded (by Func; author: Func):

[mediawiki/extensions/CodeMirror@master] ve.ui: Set the CE wrapper to the appropriate language

https://gerrit.wikimedia.org/r/935871

Change 935871 merged by jenkins-bot:

[mediawiki/extensions/CodeMirror@master] ve.ui: Set the CM wrapper to the appropriate language

https://gerrit.wikimedia.org/r/935871

Func claimed this task.