Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Split measuring of long/huge lines #1022

Closed
marijnh opened this Issue · 3 comments

2 participants

@marijnh
Owner

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).

@marijnh
Owner

[This is a significant effort that I'll probably only undertake when sponsors step up.]

@nicolacity

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.

@marijnh marijnh referenced this issue from a commit
@marijnh marijnh Experimental option crudeMeasuringFrom
Stopgap for #1022
b88e8c3
@marijnh
Owner

The lazy measuring is implemented in the v4 branch. Lazy drawing is planned, further tracked by #2090

@marijnh marijnh closed this
@anaran anaran referenced this issue from a commit in anaran/CodeMirror
@marijnh marijnh Experimental option crudeMeasuringFrom
Stopgap for #1022
dae618f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.