Files
cdnjs/ajax/libs/codemirror/2.36.0/continuecomment.min.js
T
2013-04-14 11:51:00 +10:00

1 line
894 B
JavaScript

(function(){for(var e=["clike","css","javascript"],t=0;e.length>t;++t)CodeMirror.extendMode(e[t],{blockCommentStart:"/*",blockCommentEnd:"*/",blockCommentContinue:" * "});CodeMirror.commands.newlineAndIndentContinueComment=function(e){var t,n=e.getCursor(),i=e.getTokenAt(n),a=CodeMirror.innerMode(e.getMode(),i.state).mode;if("comment"==i.className&&a.blockCommentStart){var r,o=i.string.indexOf(a.blockCommentEnd),s=e.getRange({line:n.line,ch:0},{line:n.line,ch:i.end});if(-1!=o&&o==i.string.length-a.blockCommentEnd.length);else if(0==i.string.indexOf(a.blockCommentStart)){if(t=s.slice(0,i.start),!/^\s*$/.test(t)){t="";for(var l=0;i.start>l;++l)t+=" "}}else-1!=(r=s.indexOf(a.blockCommentContinue))&&r+a.blockCommentContinue.length>i.start&&/^\s*$/.test(s.slice(0,r))&&(t=s.slice(0,r))}null!=t?e.replaceSelection("\n"+t+a.blockCommentContinue,"end"):e.execCommand("newlineAndIndent")}})();