CodeMirror uses lines as the units for redrawing and measuring text metrics. This works great for typical documents, but falls apart when there are a huge (50k+) number of characters on a single line.
It should be possible to, when this situation occurs, somehow break up the line in such a way that changes to it don't inccur a giant amount of repeated work.
It seems that redrawing/relayouting the line, when something near its start changes, is unavoidable. However, the major bottleneck is measuring. A huge gain could probably be gained by splitting the measuring information in ~1000char chunks, and lazily remeasuring it as-needed. When the start changes, we probably only need information about the start of the line (to place cursor etc), so we'd only have to re-measure a small part of the line. When something near middle changes, existing metrics from the start can be used to 'offset' the re-measurement of the text around the cursor.
One very tricky point here is to make sure wrapping, if enabled, still behaves precisely the same in the rendered sub-lines as in the whole line. When lineWrapping is on, we'd probably want to make our chunk splits on wrap points (which can be deduced from previous metric data).
[This is a significant effort that I'll probably only undertake when sponsors step up.]
Would it be possible to solve the major performance issues on long lines before tackling this more robust solution? I'm seeing a major regression since v2 with extremely long line lengths.
Experimental option crudeMeasuringFrom
Stopgap for #1022
The lazy measuring is implemented in the v4 branch. Lazy drawing is planned, further tracked by #2090