Gruntfuggly / todo-tree

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

[BUG] Tags are matching at the start of a line #768

Open cfgnunes opened 1 year ago

cfgnunes commented 1 year ago

Reason

The symbol '^' in the regex causes the matching of tags at the start of a line.

Details of implications

The regex of Todo Tree has the symbol “^” that asserts position at the start of a line. The problem occurs because there are many general matches and causes many false matching. See some examples below.

Example 1: C/C++ structs and defines.

In the Linux Kernel code (https://kernel.org), there are structs such as BUG_ON and BUG_ENTRY in many parts of the code.

BUG_ENTRY(PPC_TLNEI " %4, 0", 0, "r" ((__force long)(x)));

So, the extension will match all structs. This behavior should not be expected.

Example 2: Text or LaTeX files.

If you write a text in LaTeX starting with:

BUG is an insect.

The extension will match part of the text. This behavior should not be expected.

Example 3: Functions in shell scripts.

BUG_HANDLER () {
    echo "Test"
}

The extension will match the function BUG_HANDLER. This behavior should not be expected.

cfgnunes commented 1 year ago

I've fixed this bug on Pull Request #767. Please, @Gruntfuggly accept the PR. 😊