Page MenuHomePhabricator

Unclosed parser function or template with a trailing pipe causes bad state with code folding enabled
Closed, ResolvedPublicBUG REPORT

Description

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

  • Start editing/creating a page with CodeMirror 6.
  • Ensure the code folding feature is enabled.
  • Open two curly brackets, type in a template name or function name, then follow by a pipe. Make sure nothing follows the pipe as that brings the editor back to a correct state. For example:
|<!--Cost-->{{#if:{{{cost|}}}|

or minimal case:

{{A|
  • Try to reposition the cursor with arrow keys or mouse.

What happens?:
Cursor desyncs as editor state's unable to be updated. An exception is thrown:

Uncaught TypeError: can't access property "name", node is null
    isComponent codemirror.mediawiki.codeFolding.js:39
    isTemplateDelimiter codemirror.mediawiki.codeFolding.js:75
    foldable codemirror.mediawiki.codeFolding.js:185
    create codemirror.mediawiki.codeFolding.js:228
    update codemirror.mediawiki.codeFolding.js:476
    update codemirror6.bundle.lib.js:1851
    applyTransaction codemirror6.bundle.lib.js:2692
    ensureAddr codemirror6.bundle.lib.js:2092
    EditorState codemirror6.bundle.lib.js:2628
    applyTransaction codemirror6.bundle.lib.js:2692
    get state codemirror6.bundle.lib.js:2342
    update codemirror6.bundle.lib.js:11792
    dispatchTransactions codemirror6.bundle.lib.js:11750
    dispatch codemirror6.bundle.lib.js:11774
    applyDOMChange codemirror6.bundle.lib.js:8256
    flush codemirror6.bundle.lib.js:11306
    onSelectionChange codemirror6.bundle.lib.js:11099
codemirror.mediawiki.codeFolding.js:39:18

What should have happened instead?:

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):
0876c38 - live on WMF wikis at the time of this ticket

Other information (browser name/version, screenshots, etc.):
Firefox 145.0.2 on Windows, but reproducible on macOS and with Chrome too.

Details

Event Timeline

Alex44019 updated the task description. (Show Details)

Change #1217819 had a related patch set uploaded (by Bhsd; author: Bhsd):

[mediawiki/extensions/CodeMirror@master] codeFolding: check if node is null

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

Change #1217819 merged by jenkins-bot:

[mediawiki/extensions/CodeMirror@master] codeFolding: check if node is null

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

Bhsd moved this task from Bugs to Done on the MediaWiki-extensions-CodeMirror board.