diff --git a/HISTORY.md b/HISTORY.md index 6689cda..5f670df 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -2,6 +2,11 @@ https://github.com/josdejong/jsoneditor +## not yet released, version 5.24.7 + +- Fix #582: parse error annotations not always up to date in + code editor. + ## 2018-09-12, version 5.24.6 diff --git a/src/js/textmode.js b/src/js/textmode.js index b91ffca..721bbf4 100644 --- a/src/js/textmode.js +++ b/src/js/textmode.js @@ -530,8 +530,19 @@ textmode._emitSelectionChange = function () { } } -textmode._refreshAnnotations = function () { - this.aceEditor && this.aceEditor.getSession().setAnnotations(); +/** + * refresh ERROR annotations state + * error annotations are handled by the ace json mode (ace/mode/json) + * validation annotations are handled by this mode + * therefore in order to refresh we send only the annotations of error type in order to maintain its state + * @private + */ +textmode._refreshAnnotations = function () { + var session = this.aceEditor && this.aceEditor.getSession(); + if (session) { + var errEnnotations = session.getAnnotations().filter(function(annotation) {return annotation.type === 'error' }); + session.setAnnotations(errEnnotations); + } } /**