From cb2b3c828f1288ff75c49205a4b2dcd4e5347135 Mon Sep 17 00:00:00 2001 From: David Braun Date: Sat, 16 Feb 2013 15:55:04 -0300 Subject: [PATCH 1/3] Create test for annotations. --- lib/ace/edit_session_test.js | 10 ++++++++++ 1 file changed, 10 insertions(+) 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]); } }; From 64b888d383b694c21ef43fc9f68e000d47c01a94 Mon Sep 17 00:00:00 2001 From: David Braun Date: Sat, 16 Feb 2013 15:55:39 -0300 Subject: [PATCH 2/3] Fix comment in setAnnotations. It returns an Array, not an Object. --- lib/ace/edit_session.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index 146c8b19..0c7ac769 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 || []; From ec6053a57cdb6e39f890ffe844a8431d5151d8b9 Mon Sep 17 00:00:00 2001 From: David Braun Date: Sat, 16 Feb 2013 16:32:06 -0300 Subject: [PATCH 3/3] Refactor clearAnnotations. --- lib/ace/edit_session.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index 0c7ac769..24a654dd 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -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([]); }; /**