better-comments icon indicating copy to clipboard operation
better-comments copied to clipboard

Strings Being Treated as Comments

Open FloatingSunfish opened this issue 4 years ago • 9 comments

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.

FloatingSunfish avatar Feb 03 '21 06:02 FloatingSunfish

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.

haimat avatar Feb 25 '21 11:02 haimat

@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 avatar Feb 26 '21 05:02 FloatingSunfish

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.

FloatingSunfish avatar Mar 16 '21 02:03 FloatingSunfish

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?

haimat avatar Mar 16 '21 08:03 haimat

@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.

FloatingSunfish avatar Mar 16 '21 08:03 FloatingSunfish

@FloatingSunfish Unerstood, thanks!

haimat avatar Mar 16 '21 08:03 haimat

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

Demetri0 avatar Apr 28 '21 11:04 Demetri0

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

AljnIstari avatar Jun 17 '21 08:06 AljnIstari

2021-06-30_222239

TolyanDimov avatar Jun 30 '21 19:06 TolyanDimov