Commit fec380dd for codemirror.net
commit fec380ddc125419ab2ba47765442ea557a88d611
Author: David Foster <david.foster@techsmart.codes>
Date: Mon Apr 22 12:46:40 2024 -0700
Add regression test for issue #1975
diff --git a/test/comment_test.js b/test/comment_test.js
index 22106671..7612f47e 100644
--- a/test/comment_test.js
+++ b/test/comment_test.js
@@ -120,4 +120,16 @@ namespace = "comment_";
cm.execCommand("selectAll")
cm.execCommand("toggleComment")
}, "/* foo */\na\n/* bar */\nb", "// /* foo */\n// a\n// /* bar */\n// b")
+
+ var before = 'console.log("//string gets corrupted.");';
+ var after = '// console.log("//string gets corrupted.");';
+ test("toggleWithStringContainingComment1", "javascript", function(cm) {
+ cm.setCursor({line: 0, ch: 16 /* after // inside string */});
+ cm.execCommand("toggleComment");
+ }, before, after)
+ test("toggleWithStringContainingComment2", "javascript", function(cm) {
+ cm.setCursor({line: 0, ch: 16 /* after // inside string */});
+ cm.execCommand("toggleComment");
+ cm.execCommand("toggleComment");
+ }, before, before)
})();