aaron-bond / better-comments

https://marketplace.visualstudio.com/items?itemName=aaron-bond.better-comments
MIT License
849 stars 161 forks source link

Strings Being Treated as Comments #308

Open FloatingSunfish opened 3 years ago

FloatingSunfish commented 3 years ago

Below are my settings:

"better-comments.multilineComments": true,
"better-comments.highlightPlainText": false,
"better-comments.tags": [
    {
        // Make all comments red and italic.
        "tag": "",
        "color": "#FF2D00",
        "strikethrough": false,
        "underline": false,
        "backgroundColor": "transparent",
        "bold": false,
        "italic": true
    }
]

The above works correctly for regular comments.

However, even for strings, comment stylization is kicking in:

href="https://mysite.com"

Above, everything from // gets stylized.

Changing the tag setting to a single space still triggers the issue:

"tag": " ",

Below is the same string, but with a space added after //:

href="https:// mysite.com"

Above, everything from // gets stylized.

It seems that Better Comments gets confused when strings contain things that look like comments.

haimat commented 3 years ago

I can confirm this for Python too. I have a string like this:

var = "This is a text with a #sign"

In this case above the word "sign" becomes grayed out and striked through. Which should not happen, since its part of a string.

FloatingSunfish commented 3 years ago

@haimat Thanks for confirming this issue in another language! 🙂 Please give the OP a Thumbs Up so the dev can add it to their backlog!

FloatingSunfish commented 3 years ago

Because the dev seems to be inactive for now, I found a workaround:

"editor.tokenColorCustomizations": {
    // Make all comments Red.
    "comments": "#FF2D00"
}

Won't be needing this extension anymore, but I'm keeping this issue open so the dev can fix it for those who do want to use this extension.

haimat commented 3 years ago

Because the dev seems to be inactive for now, I found a workaround:

"editor.tokenColorCustomizations": {
    // Make all comments Red.
    "comments": "#FF2D00"
}

Won't be needing this extension anymore, but I'm keeping this issue open so the dev can fix it for those who do want to use this extension.

Could you please elaborate - how is this a workaround for this issue?

FloatingSunfish commented 3 years ago

@haimat My apologies for the confusion. I meant a workaround for my specific case, as I was only using this extension to make my comments stand out by making them Red.

Now that I have a way to recolor my comments, I have no further use for this extension, but I want to keep this issue open so the dev can see it and potentially fix it for those who still want to use this extension.

haimat commented 3 years ago

@FloatingSunfish Unerstood, thanks!

Demetri0 commented 3 years ago

Screenshot from 2021-04-28 17-19-18

AljnIstari commented 3 years ago

Just confirming the same issue with TypeScript/JS.

I've tested both single-quote ( ' ) and double-quote ( " ) strings, and template literals ( ` ).

It is present for properly formed single-line (//), block (/* */), and JavaDoc (/** */) comments.

Example below:

comments

TolyanDimov commented 3 years ago

2021-06-30_222239