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

Tag matching regex is too aggressive, should not ignore whitespace

Open lonix1 opened this issue 3 years ago • 2 comments

These comments are shown in red:

//! foo bar baz
// ! foo bar baz

But sometimes you don't want that:

// algorithm to determine foo
//   iserror: remember to do bar
//   !iserror: skip baz               <------ shown in red, incorrectly

The regex probably has this: \/\/\w*!. So it ignores the whitespace between // and !.

It would be helpful to be able to enforce only two types: //! foo and // ! foo. (Using a new backwards-compatible option, of course.)

lonix1 avatar Aug 13 '22 01:08 lonix1

Good idea. I think I'm somewhat reluctant to change behaviour these days, but I could maybe see something this working OK:

// ! this is coloured
//! this is coloured
// !this is not coloured

I would guess that last one is not a common use-case, and if I limit that one, it'll solve your issue also. Thoughts?

aaron-bond avatar Oct 16 '22 13:10 aaron-bond

Probably good enough. That extra whitespace causes the issue, so ignoring would help. Hiding this behind an option would make everyone happy.

lonix1 avatar Oct 16 '22 13:10 lonix1