Page MenuHomePhabricator

Syntax highlight misalignment in 2017 wikitext editor
Open, Needs TriagePublic

Description

  1. Open https://en.wikipedia.beta.wmflabs.org/wiki/Code_mirror_test in 2017WTE
  2. Enable syntax highlighting

Observe that [[hello world]] moves one character to the right, as the double space at the end of the line of dots wraps in CodeMirror, but not VE.

Misalignments of the surfaces makes editing the document beyond this point nearly impossible.

Event Timeline

I know we've played around with the CSS for whitespace a lot in the past to correct issues like this. It appears that CodeMirror rendering the double spaces as "  " may have something to do with it. Also the square bracket affects the logic, as replacing "[[" with "xx" makes the issue go away. So this could be a regression from the bracket highlighting work that was done...

It's specifically a Firefox issue -- I can't reproduce it in Chrome or Safari.

I'm testing in Chrome. Try adding more spaces between the dots and the link.

We should probably use white-spaces: break-spaces now that we've dropped IE support (https://caniuse.com/mdn-css_properties_white-space_break-spaces). Using this instead of pre-wrap means that whitespace at the end of a line (and more importantly multiple whitespace) does not get hidden.

This fixes my test case above, although more complex cases still break, so I'll try and write a minimal test case for that.

Change 963065 had a related patch set uploaded (by Esanders; author: Esanders):

[mediawiki/extensions/CodeMirror@master] Use white-space: break-spaces

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

Change 963065 merged by jenkins-bot:

[mediawiki/extensions/CodeMirror@master] Use white-space: break-spaces

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