]> git.r.bdr.sh - rbdr/dotfiles/blame - atom/packages/pretty-json/node_modules/jsonminify/report/assets/scripts/vendor/codemirror/util/continuecomment.js
Remove mc config
[rbdr/dotfiles] / atom / packages / pretty-json / node_modules / jsonminify / report / assets / scripts / vendor / codemirror / util / continuecomment.js
CommitLineData
06a3d686
BB
1(function() {
2 var modes = ["clike", "css", "javascript"];
3 for (var i = 0; i < modes.length; ++i)
4 CodeMirror.extendMode(modes[i], {blockCommentStart: "/*",
5 blockCommentEnd: "*/",
6 blockCommentContinue: " * "});
7
8 CodeMirror.commands.newlineAndIndentContinueComment = function(cm) {
9 var pos = cm.getCursor(), token = cm.getTokenAt(pos);
10 var mode = CodeMirror.innerMode(cm.getMode(), token.state).mode;
11 var space;
12
13 if (token.type == "comment" && mode.blockCommentStart) {
14 var end = token.string.indexOf(mode.blockCommentEnd);
15 var full = cm.getRange({line: pos.line, ch: 0}, {line: pos.line, ch: token.end}), found;
16 if (end != -1 && end == token.string.length - mode.blockCommentEnd.length) {
17 // Comment ended, don't continue it
18 } else if (token.string.indexOf(mode.blockCommentStart) == 0) {
19 space = full.slice(0, token.start);
20 if (!/^\s*$/.test(space)) {
21 space = "";
22 for (var i = 0; i < token.start; ++i) space += " ";
23 }
24 } else if ((found = full.indexOf(mode.blockCommentContinue)) != -1 &&
25 found + mode.blockCommentContinue.length > token.start &&
26 /^\s*$/.test(full.slice(0, found))) {
27 space = full.slice(0, found);
28 }
29 }
30
31 if (space != null)
32 cm.replaceSelection("\n" + space + mode.blockCommentContinue, "end");
33 else
34 cm.execCommand("newlineAndIndent");
35 };
36})();