diff --git a/addon/comment/comment.js b/addon/comment/comment.js index 2c4f975d08f59cc3f2e5d4d5a9933ef2c1ec5cc8..2f2f071df974d7b746420f6a67677c9abe307bf2 100644 --- a/addon/comment/comment.js +++ b/addon/comment/comment.js @@ -140,7 +140,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); } diff --git a/test/comment_test.js b/test/comment_test.js index 26e474493b19c5ef99714bdfa48de28bb82693f9..3e6a86bbf2ff752642e02425bbd3e0c1b057254a 100644 --- a/test/comment_test.js +++ b/test/comment_test.js @@ -97,4 +97,9 @@ namespace = "comment_"; test("dontMessWithStrings3", "javascript", function(cm) { cm.execCommand("toggleComment"); }, "// console.log(\"// string\");", "console.log(\"// string\");"); + + test("includeLastLine", "javascript", function(cm) { + cm.execCommand("selectAll") + cm.execCommand("toggleComment") + }, "// foo\n// bar\nbaz", "// // foo\n// // bar\n// baz") })();