From 4adafb6d1e7c9d9a8285820d19bd664f579be3a0 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Sun, 14 Jan 2018 13:24:12 +0000 Subject: [PATCH] Changes to ACE editor annotations relax errors for missing semi-colons, [] syntax warnings, max errors. And also ignore missing doctype error for html templates. --- editor/js/ui/editor.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/editor/js/ui/editor.js b/editor/js/ui/editor.js index 8997d0839..33dd3ce64 100644 --- a/editor/js/ui/editor.js +++ b/editor/js/ui/editor.js @@ -2389,6 +2389,16 @@ RED.editor = (function() { var editor = ace.edit(options.id); editor.setTheme("ace/theme/tomorrow"); var session = editor.getSession(); + session.on("changeAnnotation", function () { + var annotations = session.getAnnotations() || []; + var i = annotations.length; + var len = annotations.length; + while (i--) { + if (/doctype first\. Expected/.test(annotations[i].text)) { annotations.splice(i, 1); } + else if (/Unexpected End of file\. Expected/.test(annotations[i].text)) { annotations.splice(i, 1); } + } + if (len > annotations.length) { session.setAnnotations(annotations); } + }); if (options.mode) { session.setMode(options.mode); } @@ -2419,7 +2429,7 @@ RED.editor = (function() { if (options.globals) { setTimeout(function() { if (!!session.$worker) { - session.$worker.send("setOptions", [{globals: options.globals, esversion:6}]); + session.$worker.send("setOptions", [{globals: options.globals, esversion:6, sub:true, asi:true, maxerr:1000}]); } },100); }