do not group annotations by rows since whole array is replaced every time
This commit is contained in:
parent
d03f2ae38b
commit
82550104db
2 changed files with 20 additions and 31 deletions
|
|
@ -752,15 +752,7 @@ var EditSession = function(text, mode) {
|
||||||
* Sets annotations for the `EditSession`. This functions emits the `'changeAnnotation'` event.
|
* Sets annotations for the `EditSession`. This functions emits the `'changeAnnotation'` event.
|
||||||
**/
|
**/
|
||||||
this.setAnnotations = function(annotations) {
|
this.setAnnotations = function(annotations) {
|
||||||
this.$annotations = {};
|
this.$annotations = annotations;
|
||||||
for (var i=0; i<annotations.length; i++) {
|
|
||||||
var annotation = annotations[i];
|
|
||||||
var row = annotation.row;
|
|
||||||
if (this.$annotations[row])
|
|
||||||
this.$annotations[row].push(annotation);
|
|
||||||
else
|
|
||||||
this.$annotations[row] = [annotation];
|
|
||||||
}
|
|
||||||
this._emit("changeAnnotation", {});
|
this._emit("changeAnnotation", {});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,28 +72,25 @@ var Gutter = function(parentEl) {
|
||||||
|
|
||||||
this.setAnnotations = function(annotations) {
|
this.setAnnotations = function(annotations) {
|
||||||
// iterate over sparse array
|
// iterate over sparse array
|
||||||
this.$annotations = [];
|
this.$annotations = []
|
||||||
for (var row in annotations) if (annotations.hasOwnProperty(row)) {
|
var rowInfo, row;
|
||||||
var rowAnnotations = annotations[row];
|
for (var i = 0; i < annotations.length; i++) {
|
||||||
if (!rowAnnotations)
|
var annotation = annotations[i];
|
||||||
continue;
|
var row = annotation.row;
|
||||||
|
var rowInfo = this.$annotations[row];
|
||||||
var rowInfo = this.$annotations[row] = {
|
if (!rowInfo) {
|
||||||
text: []
|
rowInfo = this.$annotations[row] = {text: []};
|
||||||
};
|
|
||||||
for (var i=0; i<rowAnnotations.length; i++) {
|
|
||||||
var annotation = rowAnnotations[i];
|
|
||||||
var annoText = annotation.text.replace(/"/g, """).replace(/'/g, "’").replace(/</, "<");
|
|
||||||
if (rowInfo.text.indexOf(annoText) === -1)
|
|
||||||
rowInfo.text.push(annoText);
|
|
||||||
var type = annotation.type;
|
|
||||||
if (type == "error")
|
|
||||||
rowInfo.className = " ace_error";
|
|
||||||
else if (type == "warning" && rowInfo.className != " ace_error")
|
|
||||||
rowInfo.className = " ace_warning";
|
|
||||||
else if (type == "info" && (!rowInfo.className))
|
|
||||||
rowInfo.className = " ace_info";
|
|
||||||
}
|
}
|
||||||
|
var annoText = annotation.text.replace(/"/g, """).replace(/'/g, "’").replace(/</g, "<");
|
||||||
|
if (rowInfo.text.indexOf(annoText) === -1)
|
||||||
|
rowInfo.text.push(annoText);
|
||||||
|
var type = annotation.type;
|
||||||
|
if (type == "error")
|
||||||
|
rowInfo.className = " ace_error";
|
||||||
|
else if (type == "warning" && rowInfo.className != " ace_error")
|
||||||
|
rowInfo.className = " ace_warning";
|
||||||
|
else if (type == "info" && (!rowInfo.className))
|
||||||
|
rowInfo.className = " ace_info";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue