diff options
Diffstat (limited to 'public/vendor/codemirror/addon/comment')
-rw-r--r-- | public/vendor/codemirror/addon/comment/comment.js | 13 |
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; |