Skip to content

Commit 66c68db

Browse files
committed
[comment addon] When uncommenting a block comment, make sure its a single one
Closes codemirror#4641
1 parent 27bfaba commit 66c68db

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

addon/comment/comment.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
// Rough heuristic to try and detect lines that are part of multi-line string
4848
function probablyInsideString(cm, pos, line) {
49-
return /\bstring\b/.test(cm.getTokenTypeAt(Pos(pos.line, 0))) && !/^[\'\"`]/.test(line)
49+
return /\bstring\b/.test(cm.getTokenTypeAt(Pos(pos.line, 0))) && !/^[\'\"\`]/.test(line)
5050
}
5151

5252
function getMode(cm, pos) {
@@ -176,9 +176,11 @@
176176
endLine = self.getLine(--end);
177177
close = endLine.indexOf(endString);
178178
}
179+
var insideStart = Pos(start, open + 1), insideEnd = Pos(end, close + 1)
179180
if (close == -1 ||
180-
!/comment/.test(self.getTokenTypeAt(Pos(start, open + 1))) ||
181-
!/comment/.test(self.getTokenTypeAt(Pos(end, close + 1))))
181+
!/comment/.test(self.getTokenTypeAt(insideStart)) ||
182+
!/comment/.test(self.getTokenTypeAt(insideEnd)) ||
183+
self.getRange(insideStart, insideEnd, "\n").indexOf(endString) > -1)
182184
return false;
183185

184186
// Avoid killing block comments completely outside the selection.

0 commit comments

Comments
 (0)