diff --git a/lib/ace/ext/beautify.js b/lib/ace/ext/beautify.js index 41fb1357c7c..b4134b81a1d 100644 --- a/lib/ace/ext/beautify.js +++ b/lib/ace/ext/beautify.js @@ -44,7 +44,7 @@ exports.singletonTags = ["area", "base", "br", "col", "command", "embed", "hr", // insert a line break after block level tags exports.blockTags = ["article", "aside", "blockquote", "body", "div", "dl", "fieldset", "footer", "form", "head", "header", "html", "nav", "ol", "p", "script", "section", "style", "table", "tbody", "tfoot", "thead", "ul"]; -exports.beautify = function(session) { +exports.beautify = function(session, options = {useRequestAnimationFrame:false}) { var iterator = new TokenIterator(session, 0, 0); var token = iterator.getCurrentToken(); var tabString = session.getTabString(); @@ -77,6 +77,7 @@ exports.beautify = function(session) { var levels = {0: 0}; var parents = []; var caseBody = false; + var id; var trimNext = function() { if (nextToken && nextToken.value && nextToken.type !== 'string.regexp') @@ -409,8 +410,8 @@ exports.beautify = function(session) { token = nextToken; } - var id; - if(window.requestAnimationFrame){ + + if(options.useRequestAnimationFrame && window.requestAnimationFrame){ id = requestAnimationFrame(function loop (){ if(token !== null) { try{