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.
|
||||
**/
|
||||
this.setAnnotations = function(annotations) {
|
||||
this.$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.$annotations = annotations;
|
||||
this._emit("changeAnnotation", {});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ var Gutter = function(parentEl) {
|
|||
(function() {
|
||||
|
||||
oop.implement(this, EventEmitter);
|
||||
|
||||
|
||||
this.setSession = function(session) {
|
||||
if (this.session)
|
||||
this.session.removeEventListener("change", this.$updateAnnotations);
|
||||
|
|
@ -72,28 +72,25 @@ var Gutter = function(parentEl) {
|
|||
|
||||
this.setAnnotations = function(annotations) {
|
||||
// iterate over sparse array
|
||||
this.$annotations = [];
|
||||
for (var row in annotations) if (annotations.hasOwnProperty(row)) {
|
||||
var rowAnnotations = annotations[row];
|
||||
if (!rowAnnotations)
|
||||
continue;
|
||||
|
||||
var 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";
|
||||
this.$annotations = []
|
||||
var rowInfo, row;
|
||||
for (var i = 0; i < annotations.length; i++) {
|
||||
var annotation = annotations[i];
|
||||
var row = annotation.row;
|
||||
var rowInfo = this.$annotations[row];
|
||||
if (!rowInfo) {
|
||||
rowInfo = this.$annotations[row] = {text: []};
|
||||
}
|
||||
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