|
103 | 103 | self.lineComment(from, to, options); |
104 | 104 | return; |
105 | 105 | } |
| 106 | + if (/\bcomment\b/.test(self.getTokenTypeAt(Pos(from.line, 0)))) return |
106 | 107 |
|
107 | 108 | var end = Math.min(to.line, self.lastLine()); |
108 | 109 | if (end != from.line && to.ch == 0 && nonWS.test(self.getLine(end))) --end; |
|
140 | 141 | var line = self.getLine(i); |
141 | 142 | var found = line.indexOf(lineString); |
142 | 143 | if (found > -1 && !/comment/.test(self.getTokenTypeAt(Pos(i, found + 1)))) found = -1; |
143 | | - if (found == -1 && (i != end || i == start) && nonWS.test(line)) break lineComment; |
| 144 | + if (found == -1 && nonWS.test(line)) break lineComment; |
144 | 145 | if (found > -1 && nonWS.test(line.slice(0, found))) break lineComment; |
145 | 146 | lines.push(line); |
146 | 147 | } |
|
162 | 163 | var endString = options.blockCommentEnd || mode.blockCommentEnd; |
163 | 164 | if (!startString || !endString) return false; |
164 | 165 | var lead = options.blockCommentLead || mode.blockCommentLead; |
165 | | - var startLine = self.getLine(start), endLine = end == start ? startLine : self.getLine(end); |
166 | | - var open = startLine.indexOf(startString), close = endLine.lastIndexOf(endString); |
| 166 | + var startLine = self.getLine(start), open = startLine.indexOf(startString) |
| 167 | + if (open == -1) return false |
| 168 | + var endLine = end == start ? startLine : self.getLine(end) |
| 169 | + var close = endLine.indexOf(endString, end == start ? open + startString.length : 0); |
167 | 170 | if (close == -1 && start != end) { |
168 | 171 | endLine = self.getLine(--end); |
169 | | - close = endLine.lastIndexOf(endString); |
| 172 | + close = endLine.indexOf(endString); |
170 | 173 | } |
171 | | - if (open == -1 || close == -1 || |
| 174 | + if (close == -1 || |
172 | 175 | !/comment/.test(self.getTokenTypeAt(Pos(start, open + 1))) || |
173 | 176 | !/comment/.test(self.getTokenTypeAt(Pos(end, close + 1)))) |
174 | 177 | return false; |
|
0 commit comments