Gruntfuggly / todo-tree

Use ripgrep to find TODO tags and display the results in a tree view
Other
1.41k stars 135 forks source link

[BUG] Rule matching is too sensitive #666

Closed shaonianruntu closed 1 year ago

shaonianruntu commented 1 year ago

Rule matching is too sensitive, and the matching content will not only focus on the annotation, but also match the code.

For example, following is my configuration of todo-tree:

"todo-tree.general.tags": [
    // "BUG",
    // "HACK",
    // "FIXME",
    // "TODO",
    // "XXX",
    // "[ ]",
    // "[x]",
    "?",
    "^",
    "~",
    "-",
    "+"
  ],
  "todo-tree.highlights.customHighlight": {
    // flag of question
    "?": {
      "type": "text-and-comment",
      "foreground": "Gold",
      "icon": "question",
      "gutterIcon": true,
      "iconColour": "Gold"
    },

I hope it can match such annotation format like “//~ [balabala]”.

However, there is destructor function in C++, and the function name begins with ~,like "~functionName()". These statements are not annotation, but they will also be overmatched by todo-tree. I think it is a big error.

And also, todo-tree will do not only match "//~ [balabala]", but also match the statement like "//~~~", or "~~~~~" in C++.

*I hope it can only match the statement like "//~ comment" or "// ~ comment" in C++. (regex: ^[FLAG]\x20.$) rather than match "~", "~function", "~~", "//~~".* (regex: ^[FLAG].$)

Is there something wrong with my rule configuration? Or is it a problem that todo-tree matching is too sensitive.

Hoping your help.

Thanks & Regards Nan

Elias-Graf commented 1 year ago

Could potentially be related to #667. E.g. that the extension has issue with special regex characters?

(Yes, I've deleted a previous comment, because I've misread what you wrote)

shaonianruntu commented 1 year ago

Could potentially be related to #667. E.g. that the extension has issue with special regex characters?

(Yes, I've deleted a previous comment, because I've misread what you wrote)

No related.

This is really difficult to express.

But what I mean,

the commonly used C++ annotation format is //.

If I set + as a todo-tree tag. The result I want is to mark is sentences begin with //+ or // +. e.g, return 0; // + to add some function before here

But the result now is that it will mark all the "+" in the file, not only labeling + under the annotation statement, but also the plus sign in the operation expression. e.g. a = 1 + 2;

It seems that the regular object is +, not //~ or // ~.

maxaxehax commented 1 year ago

@shaonianruntu This works perfectly fine for me. You have set the wrong regex expression, where you are not prefixing your + tag with the // line-comment opener for your language of choice.

Use regexr.com and the "todo-tree.regex.regex" setting and double check your settings.

shaonianruntu commented 1 year ago

@shaonianruntu This works perfectly fine for me. You have set the wrong regex expression, where you are not prefixing your + tag with the // line-comment opener for your language of choice.

Use regexr.com and the "todo-tree.regex.regex" setting and double check your settings.

Thank you very much. You are right! I should add // before myself define tags, like // todo or // +, ... rather than todo or +

Thanks