]>
git.r.bdr.sh - rbdr/dotfiles/blob - atom/packages/pretty-json/node_modules/jsonminify/report/assets/scripts/vendor/codemirror/util/continuecomment.js
2 var modes
= ["clike", "css", "javascript"];
3 for (var i
= 0; i
< modes
.length
; ++i
)
4 CodeMirror
.extendMode(modes
[i
], {blockCommentStart: "/*",
6 blockCommentContinue: " * "});
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
;
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
)) {
22 for (var i
= 0; i
< token
.start
; ++i
) space
+= " ";
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
);
32 cm
.replaceSelection("\n" + space
+ mode
.blockCommentContinue
, "end");
34 cm
.execCommand("newlineAndIndent");