use objects instead of sparse arrays
This commit is contained in:
parent
5a0bd89c79
commit
4010fad254
2 changed files with 7 additions and 4 deletions
|
|
@ -214,7 +214,7 @@ var EditSession = function(text, mode) {
|
|||
* }
|
||||
*/
|
||||
this.setAnnotations = function(annotations) {
|
||||
this.$annotations = [];
|
||||
this.$annotations = {};
|
||||
for (var i=0; i<annotations.length; i++) {
|
||||
var annotation = annotations[i];
|
||||
var row = annotation.row;
|
||||
|
|
@ -231,7 +231,7 @@ var EditSession = function(text, mode) {
|
|||
};
|
||||
|
||||
this.clearAnnotations = function() {
|
||||
this.$annotations = [];
|
||||
this.$annotations = {};
|
||||
this._dispatchEvent("changeAnnotation", {});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -72,12 +72,15 @@ var Gutter = function(parentEl) {
|
|||
|
||||
this.setAnnotations = function(annotations) {
|
||||
// iterate over sparse array
|
||||
this.$annotations = [];
|
||||
this.$annotations = [];
|
||||
for (var row in annotations) {
|
||||
var rowAnnotations = annotations[row];
|
||||
if (!rowAnnotations)
|
||||
continue;
|
||||
|
||||
var rowInfo = this.$annotations[row] = {
|
||||
text: []
|
||||
};
|
||||
var rowAnnotations = annotations[row];
|
||||
for (var i=0; i<rowAnnotations.length; i++) {
|
||||
var annotation = rowAnnotations[i];
|
||||
rowInfo.text.push(annotation.text.replace(/"/g, """).replace(/'/g, "’").replace(/</, "<"));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue