This applies to legacy CodeMirror 5, not T259059: Upgrade to CodeMirror 6.
Steps to replicate the issue (include links if applicable):
- Ensure you're using the 2017 editor ("Use the wikitext mode inside the visual editor, instead of a different wikitext editor" in your editing preferences)
- Go to edit any RTL page, such as https://ar.wikipedia.org/w/index.php?title=مستخدم%3AMusikAnimal%2Fsandbox&veaction=editsource
What happens?:
The "Syntax highlighting" option is available in the Page options, and if enabled, CodeMirror is loaded (i.e. <div> tags are highlighted)
What should have happened instead?:
CodeMirror should not be available because it is an RTL page.
Other information:
CodeMirror 6 (T259059) brings RTL support, but CM6 isn't available for the 2017 editor yet (T357482). Until then, CodeMirror + 2017 editor should not be possible on RTL pages due to glaring bugs (ref).
If I understand the extension attribute VisualEditorPluginModules will unconditionally load the ext.CodeMirror.visualEditor module, and this module does not check the direction of the content. It would seem this has been this case since... always (?)