Skip to content

Commit 43d0324

Browse files
committed
[continuecomment addon] Fix issue with single-line block comments
The addon would think it still was in a block comment when one was opened and closed earlier on the line. Issue codemirror/google-modes#58
1 parent ad6635a commit 43d0324

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

addon/comment/continuecomment.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
var insert = null;
2323
if (mode.blockCommentStart && mode.blockCommentContinue) {
2424
var line = cm.getLine(pos.line).slice(0, pos.ch)
25-
var end = line.indexOf(mode.blockCommentEnd), found
25+
var end = line.lastIndexOf(mode.blockCommentEnd), found
2626
if (end != -1 && end == pos.ch - mode.blockCommentEnd.length) {
2727
// Comment ended, don't continue it
28-
} else if ((found = line.indexOf(mode.blockCommentStart)) > -1) {
28+
} else if ((found = line.lastIndexOf(mode.blockCommentStart)) > -1 && found > end) {
2929
insert = line.slice(0, found)
3030
if (/\S/.test(insert)) {
3131
insert = ""

mode/javascript/javascript.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
821821
electricInput: /^\s*(?:case .*?:|default:|\{|\})$/,
822822
blockCommentStart: jsonMode ? null : "/*",
823823
blockCommentEnd: jsonMode ? null : "*/",
824-
blockCommentContinue: jsonMode ? null : " ",
824+
blockCommentContinue: jsonMode ? null : " * ",
825825
lineComment: jsonMode ? null : "//",
826826
fold: "brace",
827827
closeBrackets: "()[]{}''\"\"``",

0 commit comments

Comments
 (0)