marijnh/CodeMirror2 — pull request #533 by njx (2012-05-09 20:07:28+00:00)
Title: Ignore hidden lines when determining maximum line length

Per our discussion on the mailing list, this patch makes it so that the maximum line length only takes visible lines into account.

Besides ignoring hidden lines in various places where we check the max length, the main logical change is in `setLineHidden()`:
1. If we're showing a line that's longer than the current longest line, then the shown line is the new longest line.
2. If we're hiding the current longest line, recompute the max line by scanning the whole document.
** This sounds wasteful, but it's the same thing `updateLinesNoUndo()` does if the longest line is dirtied and no new line in the replacement is of greater length.

To do this, I refactored out the code in `updateLinesNoUndo()` that scans the whole doc to determine the longest line (into `computeMaxLength()`). There's a new global flag, `maxLengthChanged`, which `setLineHidden()` sets in the second case above, and which causes `computeMaxLength()` to be called in `endOperation()`. That way, we only rescan the document at most once during an operation.