diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index 146c8b19..24a654dd 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -744,7 +744,7 @@ var EditSession = function(text, mode) { /** * Returns the annotations for the `EditSession`. - * @returns {Object} + * @returns {Array} **/ this.getAnnotations = function() { 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. **/ this.clearAnnotations = function() { - this.$annotations = []; - this._emit("changeAnnotation", {}); + this.setAnnotations([]); }; /** diff --git a/lib/ace/edit_session_test.js b/lib/ace/edit_session_test.js index 07d6b375..68581679 100644 --- a/lib/ace/edit_session_test.js +++ b/lib/ace/edit_session_test.js @@ -1007,6 +1007,16 @@ module.exports = { session.documentToScreenPosition(2,0); assertArray(session.$docRowCache, [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]); } };