summaryrefslogtreecommitdiff
path: root/public/vendor/codemirror/addon/comment/comment.js
diff options
context:
space:
mode:
authorWu Cheng-Han2016-10-10 21:15:29 +0800
committerWu Cheng-Han2016-10-10 21:15:29 +0800
commit795ea21191486a80437d7c535defc503962c5968 (patch)
tree434a65ec986264b2abdec29b8f6a837ca536d2dd /public/vendor/codemirror/addon/comment/comment.js
parentfb5d7e43592c1a14831067e28def9c4b9e2a97ca (diff)
Update CodeMirror to 5.19.0 and rename jade to pug
Diffstat (limited to 'public/vendor/codemirror/addon/comment/comment.js')
-rw-r--r--public/vendor/codemirror/addon/comment/comment.js13
1 files changed, 8 insertions, 5 deletions
diff --git a/public/vendor/codemirror/addon/comment/comment.js b/public/vendor/codemirror/addon/comment/comment.js
index 2c4f975d..d71cf436 100644
--- a/public/vendor/codemirror/addon/comment/comment.js
+++ b/public/vendor/codemirror/addon/comment/comment.js
@@ -103,6 +103,7 @@
self.lineComment(from, to, options);
return;
}
+ if (/\bcomment\b/.test(self.getTokenTypeAt(Pos(from.line, 0)))) return
var end = Math.min(to.line, self.lastLine());
if (end != from.line && to.ch == 0 && nonWS.test(self.getLine(end))) --end;
@@ -140,7 +141,7 @@
var line = self.getLine(i);
var found = line.indexOf(lineString);
if (found > -1 && !/comment/.test(self.getTokenTypeAt(Pos(i, found + 1)))) found = -1;
- if (found == -1 && (i != end || i == start) && nonWS.test(line)) break lineComment;
+ if (found == -1 && nonWS.test(line)) break lineComment;
if (found > -1 && nonWS.test(line.slice(0, found))) break lineComment;
lines.push(line);
}
@@ -162,13 +163,15 @@
var endString = options.blockCommentEnd || mode.blockCommentEnd;
if (!startString || !endString) return false;
var lead = options.blockCommentLead || mode.blockCommentLead;
- var startLine = self.getLine(start), endLine = end == start ? startLine : self.getLine(end);
- var open = startLine.indexOf(startString), close = endLine.lastIndexOf(endString);
+ var startLine = self.getLine(start), open = startLine.indexOf(startString)
+ if (open == -1) return false
+ var endLine = end == start ? startLine : self.getLine(end)
+ var close = endLine.indexOf(endString, end == start ? open + startString.length : 0);
if (close == -1 && start != end) {
endLine = self.getLine(--end);
- close = endLine.lastIndexOf(endString);
+ close = endLine.indexOf(endString);
}
- if (open == -1 || close == -1 ||
+ if (close == -1 ||
!/comment/.test(self.getTokenTypeAt(Pos(start, open + 1))) ||
!/comment/.test(self.getTokenTypeAt(Pos(end, close + 1))))
return false;