edwinhuish / better-comments-next

https://marketplace.visualstudio.com/items?itemName=EdwinHuiSH.better-comments-next
MIT License
33 stars 2 forks source link

Breaking changes in v3.1.20 #9

Closed tylerlaprade closed 7 months ago

tylerlaprade commented 7 months ago

Last night's release seems to have introduced multiple undesirable behavior changes. All Python comments are now neon green and bolded. Also, there seem to be some cases (not all) where a non-comment line starting with ! is red, which I think was previously fixed.

image image
edwinhuish commented 7 months ago

Could you send me an example code?

tylerlaprade commented 7 months ago

Exclamation mark at start of line:

        if (
            foo(
                x
            )
            != bar
        ):
            return
image

Comment at start of line:

# foo
image
edwinhuish commented 7 months ago

Is it python?

You must provide a full example.

In your case, it should have any irregular block comments before them cause this issues.

tylerlaprade commented 7 months ago

Is it python?

Yes.

irregular block comments

I do have a docstring beforehand. I wouldn't consider it "irregular" since it follows standard guidelines.

    def generate_foo(self):
        """Does a thing.
        And another thing
        """
        if (
            foo(
                x
            )
            != bar
        ):
            return
tylerlaprade commented 7 months ago

Okay, I experimented a bit and found that both the green comments and the red exclamation line are happening when they occur anywhere between two different docstrings - which, in a file with many functions, is going to be essentially every single comment. The logic for determining "is this a comment?" must be looking for anything between two """ pairs, even though each one should only be considered active until its closing pair.

edwinhuish commented 7 months ago

In your example, it wont cause the problem.

The only way to cause this problem should be something like below:

image

edwinhuish commented 7 months ago

I'm trying to avoid this wrong match, but it will makes the judgment very complicated and seems completely meaningless.

tylerlaprade commented 7 months ago

I have a working repro of the above where the top and bottom are both valid docstrings. One happens to be on the containing function, the other is on another class. I can't paste the full thing because it's proprietary code, hence my attempts at anonymized examples.

edwinhuish commented 7 months ago

I have a working repro of the above where the top and bottom are both valid docstrings. One happens to be on the containing function, the other is on another class. I can't paste the full thing because it's proprietary code, hence my attempts at anonymized examples.

So, give me an example pls.

tylerlaprade commented 7 months ago

Both examples are fixed for me now, thanks @edwinhuish!