Proposed changes to CodeMirror ext
When cursor is either before, after, or within any bracket or bracket set, both that bracket/set and its pair are highlighted with a background color. Should include all types of brackets and tags that exist within wikitext: < > </ >, [[ ]], { }, {{ }}, {{{ }}}. If multiple brackets function as a group, the entire group should be highlighted.
Note: CodeMirror has an existing plug-in for this that can hopefully be built on edit/matchbrackets.js.
Open questions for investigation
The following questions apply to the CodeMirror extension within two different editors. Whatever implementation we choose must include both the 2017 Wikitext editor (source view inside VE) and the 2010 wikitext editor.
- Is it possible to highlight brackets as sets, not just individually? Ex. Double and triple curly brackets {{{ }}}
- Is it possible to highlight the brackets related to the current section if cursor is in the middle?
Scope
- This ticket is not about implementing bracket matching yet, we would just like to understand better the opportunities and limitations related to the topic. By looking into what is possible and its potential difficulty, it can help in choosing what we will eventually implement within the template topic.
- In particular, given the complication of implementing the changes to CodeMirror across two editors. We would like to better understand the difficultly of implementation across these different editors, particularly the complicating factor of the stacked surfaces in VE (users interact with the transparent ‘top’ surface of VE content but they see the CodeMirror content underneath).
- The goal is to improve writing and editing templates, but any changes to CodeMirror will also affect syntax highlighting source code for other namespaces such as wikitext for articles. If this expands the needed work, would also be important to note that in this investigation.
- It has already been raised that syntax highlighting does not work in RLT (see T170001). Exploring how bracket matching does or does not affect that, unfortunately expands the scope too much for this investigation. For now, set these issues aside.
- It has also been raised that bracket matching might be particularly difficult in some non-latin writing systems, particularly Japanese and Chinese, which use IME. Solving this issue is also not part of the scope, but it would be good to understand how much this could complicate/block work in this area.
Notes
Related task: Request for bracket matching (from 2013) T15302