(function(){CodeMirror.defineExtension("autoFormatAll",function(e,p){for(var b=this,f=b.getMode(),h=b.getRange(e,p).split("\n"),k=CodeMirror.copyState(f,b.getTokenAt(e).state),q=b.getOption("tabSize"),d="",l=0,c=0==e.ch,g=0;g<h.length;++g){for(var a=new CodeMirror.StringStream(h[g],q);!a.eol();){var m=CodeMirror.innerMode(f,k),r=f.token(a,k),n=a.current();a.start=a.pos;if(!c||/\S/.test(n))d+=n,c=!1;!c&&m.mode.newlineAfterToken&&m.mode.newlineAfterToken(r,n,a.string.slice(a.pos)||h[g+1]||"",m.state)&&
(d+="\n",c=!0,++l)}!a.pos&&f.blankLine&&f.blankLine(k);!c&&g<h.length-1&&(d+="\n",c=!0,++l)}b.operation(function(){b.replaceRange(d,e,p);for(var a=e.line+1,c=e.line+l;a<=c;++a)b.indentLine(a,"smart");b.setCursor({line:0,ch:0})})})})();