CM becomes unresponsive with long lines/paragraphs

CM handles large text files without any problems, but it is almost impossible to edit long (>2000 words) wrapped lines/paragraphs. I am just wondering - is there a workaround for that problem? maxHighlightLength doesn’t help. I am using markdown mode and some other standard addons.
iztok

Which browser are you using? Things seem fine on Chrome.

I am using chromium inside nw.js (node webkit). But even if I go to:
http://codemirror.net/mode/gfm/index.html (with Chrome) and paste 2000 words line/paragraph into it, there is a detectable delay when editing.

I also noticed that the following code I use adds to that delay considerably:

// Defines overlay mode for wm comments
CodeMirror.defineOption("highlightComments", false, function(cm, val, prev) {
	if (prev == CodeMirror.Init) prev = false;
	if (prev && !val)
		cm.removeOverlay("wm-comments");
	else if (!prev && val)

		cm.addOverlay({
		name: "wm-comments",
		token: function(stream, state) {
			var ch;

			if (stream.match(/.*:\/\//)) { // exclude hyperlinks
				return null;
			} else if (stream.match("//")) {
				while ((ch = stream.next()) != null) {
					if (ch == "/" && stream.next() == "/") {
						stream.eat("/");
						return "wm-comments";
					} else if (stream.eol()) {
						return "wm-comments";
					}
				}
			}
			while (stream.next() != null && !stream.match("//", false)) {}
			return null;
		}
	});
});

You’re matching a .* backtracking regexp to the long string on every character. That will be slow, yes. Regexps passed to stream.match should always start with ^, but in this case that doesn’t solve the problem, and you’ll also need to formulate it in a way that isn’t so wasteful to match.

Thanks for pointing this out for me! I’ll try some other approach.
Regards,
iztok