Skip to content

Commit

Permalink
added options for beautify
Browse files Browse the repository at this point in the history
  • Loading branch information
salmanul committed Jan 28, 2022
1 parent 8e24460 commit a90bec6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/ace/ext/beautify.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit a90bec6

Please sign in to comment.