Skip to content

Commit

Permalink
Fix last-minute breakage in v2.17
Browse files Browse the repository at this point in the history
  • Loading branch information
marijnh committed Nov 21, 2011
1 parent 0493d68 commit 7ced0dd
Showing 1 changed file with 32 additions and 33 deletions.
65 changes: 32 additions & 33 deletions lib/codemirror.js
Expand Up @@ -1225,10 +1225,41 @@ var CodeMirror = (function() {
changes.push({from: 0, to: doc.size});
}

function TextMarker() { this.set = []; }
TextMarker.prototype.clear = operation(function() {
for (var i = 0, e = this.set.length; i < e; ++i) {
var mk = this.set[i].marked;
if (!mk) continue;
for (var j = 0; j < mk.length; ++j)
if (mk[j].set == this.set) mk.splice(j--, 1);
}
// We don't know the exact lines that changed. Refreshing is
// cheaper than finding them.
changes.push({from: 0, to: doc.size});
});
TextMarker.prototype.find = function() {
var from, to;
for (var i = 0, e = this.set.length; i < e; ++i) {
var line = this.set[i], mk = line.marked;
for (var j = 0; j < mk.length; ++j) {
var mark = mk[j];
if (mark.set == this.set) {
if (mark.from != null || mark.to != null) {
var found = lineNo(line);
if (found != null) {
if (mark.from != null) from = {line: found, ch: mark.from};
if (mark.to != null) to = {line: found, ch: mark.to};
}
}
}
}
}
return {from: from, to: to};
};

function markText(from, to, className) {
from = clipPos(from); to = clipPos(to);
var tm = new TextMarker();
tm.clear = operation(tm.clear);
function add(line, from, to, className) {
mark = getLine(line).addMark(new MarkedText(from, to, className, tm.set));
}
Expand Down Expand Up @@ -1966,38 +1997,6 @@ var CodeMirror = (function() {
};
CodeMirror.StringStream = StringStream;

function TextMarker() { this.set = []; }
TextMarker.prototype.clear = function() {
for (var i = 0, e = this.set.length; i < e; ++i) {
var mk = this.set[i].marked;
if (!mk) continue;
for (var j = 0; j < mk.length; ++j)
if (mk[j].set == this.set) mk.splice(j--, 1);
}
// We don't know the exact lines that changed. Refreshing is
// cheaper than finding them.
changes.push({from: 0, to: doc.size});
};
TextMarker.prototype.find = function() {
var from, to;
for (var i = 0, e = this.set.length; i < e; ++i) {
var line = this.set[i], mk = line.marked;
for (var j = 0; j < mk.length; ++j) {
var mark = mk[j];
if (mark.set == this.set) {
if (mark.from != null || mark.to != null) {
var found = lineNo(line);
if (found != null) {
if (mark.from != null) from = {line: found, ch: mark.from};
if (mark.to != null) to = {line: found, ch: mark.to};
}
}
}
}
}
return {from: from, to: to};
};

function MarkedText(from, to, className, set) {
this.from = from; this.to = to; this.style = className; this.set = set;
}
Expand Down

0 comments on commit 7ced0dd

Please sign in to comment.