Skip to content

Commit 91ab044

Browse files
committed
fix: [BUG]: single-line comment fails in VS Code June release
Fixes #10 In the `setSingleLineCommentLanguageDefinitions` method, it uses the `String.includes` method to detect when the `lineComment` string `includes` a semi-colon - ;. The `lineComment` the language config has changed to be either a string or an object. The object has a `comment` and `noIndent` keys. The `includes` method fails due to it being an object and errors out with "lineComment.includes is not a function". To fix: - Added a check to see if the `lineComment` is an object with a `comment` key inside, if it does then use the string value of the `comment` key. Otherwise, it will use the string value of the `lineComment`.
1 parent 7b51228 commit 91ab044

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

src/configuration.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -519,16 +519,24 @@ export class Configuration {
519519
// If the config object has own property of comments AND the comments key has
520520
// own property of lineComment...
521521
if (Object.hasOwn(config, "comments") && Object.hasOwn(config.comments, "lineComment")) {
522+
let lineComment = config.comments.lineComment;
523+
524+
// Line comments can be a string or an object with a "comment" key.
525+
// If the lineComment is an object, get the "comment" key value.
526+
if (Object.hasOwn(lineComment, "comment")) {
527+
lineComment = lineComment.comment;
528+
}
529+
522530
// If the lineComment is "//"...
523-
if (config.comments.lineComment === "//") {
531+
if (lineComment === "//") {
524532
style = "//";
525533
}
526534
// If the lineComment is "#"...
527-
else if (config.comments.lineComment === "#") {
535+
else if (lineComment === "#") {
528536
style = "#";
529537
}
530538
// If the lineComment includes a ";" (; or ;;)...
531-
else if (config.comments.lineComment.includes(";")) {
539+
else if (lineComment.includes(";")) {
532540
style = ";";
533541
}
534542

0 commit comments

Comments
 (0)