Merge pull request #1257 from BallBearing/issue1253

Give some more love to #1253.
This commit is contained in:
Harutyun Amirjanyan 2013-02-16 12:31:56 -08:00
commit f99827e01b
2 changed files with 12 additions and 3 deletions

View file

@ -744,7 +744,7 @@ var EditSession = function(text, mode) {
/** /**
* Returns the annotations for the `EditSession`. * Returns the annotations for the `EditSession`.
* @returns {Object} * @returns {Array}
**/ **/
this.getAnnotations = function() { this.getAnnotations = function() {
return this.$annotations || []; return this.$annotations || [];
@ -754,8 +754,7 @@ var EditSession = function(text, mode) {
* Clears all the annotations for this session. This function also triggers the `'changeAnnotation'` event. * Clears all the annotations for this session. This function also triggers the `'changeAnnotation'` event.
**/ **/
this.clearAnnotations = function() { this.clearAnnotations = function() {
this.$annotations = []; this.setAnnotations([]);
this._emit("changeAnnotation", {});
}; };
/** /**

View file

@ -1007,6 +1007,16 @@ module.exports = {
session.documentToScreenPosition(2,0); session.documentToScreenPosition(2,0);
assertArray(session.$docRowCache, [1,2]); assertArray(session.$docRowCache, [1,2]);
assertArray(session.$screenRowCache, [1,2]); assertArray(session.$screenRowCache, [1,2]);
},
"test annotations": function() {
var session = new EditSession([]),
annotation = {row: 0, type: 'info', text: "This is a test."};
session.clearAnnotations();
assertArray(session.getAnnotations(), []);
session.setAnnotations([annotation]);
assertArray(session.getAnnotations(), [annotation]);
} }
}; };