klembot / twinejs

Twine, a tool for telling interactive, nonlinear stories
https://twinery.org
GNU General Public License v3.0
2k stars 296 forks source link

2.4: CodeMirror crashes if a format uses cm.doc.replaceSelection() where the replacement contains a newline #1119

Open webbedspace opened 2 years ago

webbedspace commented 2 years ago

This is used by Harlowe's toolbar for block-level markup, like headers. Since they must start on a new line, the toolbar buttons runs cm.doc.replaceSelection("\n#" + wrapped, "around"); (paraphrased) where "wrapped" is whatever text was highlighted at the time.

Notably, this does NOT crash 2.3!

Some visual aides: image Fig.1. Before clicking. image Fig.2. The replacement is shown, but soon afterward... image Fig.3. The error occurs.

Twine version number

2.4.0-beta3

Does this problem occur with the web version of Twine or the desktop app?

Web

What operating system does this problem occur on?

Windows

If this problem is occurring with the web version of Twine, what browser does it occur on?

Firefox

Presubmission checklist

klembot commented 2 years ago

This reads like an issue with CM but I need to try to repro this on my side to understand better. If it's with CM, you might have to work around it. I can try upgrading CM (2.4 is on 5.65.1, there is 5.65.3) but the changelog doesn't mention this issue.