Page MenuHomePhabricator

VisualEditor insert math formula moves start of code to the end
Open, Needs TriagePublicBUG REPORT

Description

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

  • Edit a page with VisualEdtior, e.g. https://en.wikipedia.org/wiki/Example
  • Click "Insert"
  • If the menu is brief then click "More"
  • Click "Math formula"
  • Click "Standard numerical functions"
  • Click "min(x,y)"

What happens?:

This is inserted in the "Formula" box:

,y)\min(x

What should have happened instead?:
This should have been inserted:

\min(x,y)

The initial "\min(x" was incorrectly moved to the end. Many other math formulas also move the start to the end. It was reported at https://en.wikipedia.org/w/index.php?title=Wikipedia:Village_pump_(technical)&oldid=1307730131#Broken_syntax with this example: Select "matrices" and click the button with "x y v z" in two lines in square brackets. It produces:

& y \\ z & v \end{bmatrix}\begin{bmatrix} x

It should have been:

\begin{bmatrix} x & y \\ z & v \end{bmatrix}

The error appears to mainly happen when the correct expression starts with a backslash and has more than a name (letters and underscore) afterwards. The cursor ends up around the middle of the malformed code.

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

Tested in Firefox and Chrome, logged in and out.

Related Objects

Duplicates Merged Here
T402777: Maths syntax bug.