Multiline TAGS not showing correctly in the tree
Hi
I have this quite complicated regex for capturing multiline comments with tags in them:
(?:[ \t]*(//+|#|;|')[ \t]*($TAGS).*\r?\n(?:\s*\1[ \t]*.*(?:\r?\n)?)*|\/\*[ \t]*($TAGS)(?:.*?(?:\r?\n.*?)*\*\/)|<!--[ \t]*($TAGS)(?:.*(?:\r?\n.*?)*?-->))
It does work quite well, captures both C /* */ and XML <!-- --> multiline comments and comments that span over multiple lines.
Given the example:
// TODO: this is a long todo
// another line
// and yet another line
do not capture this
# TODO: C style comment
# another line
do not capture this
; TODO: This is a comment in the
; basic
do not capture this
' TODO: this is another type of
' a comment
do not capture this
/* TODO: C-style multilne
* comment
*/
do not capture this
<!-- TODO: xml style
multilne comment
-->
do not capture this
<!-- TODO: xml style
multilne comment
-->
do not capture this
// TODO: Needs to be at any depth
// continuation
do not capture this
/* TODO: Let's try
* this also
*/
do not capture this
// this shoud
// not be captured
# in any
# way
// WARN: this is another
// thing that should be captured
The problem is that what is captured is not being shown correctly in the tree:
What i see here i pretty wrong
- The text on the first line of the comment is not shown
- The following lines are being shown as sub-items, instead of being concatenated
I've tried plyaing with the Sub Tag Regex to strip newlines and comment characters from what is being matched, but I cannot get it working.
Unfortunately there was an update to ripgrep which I was unaware of which stops one of the options working how it used to, which now prevents the extension from parsing the results correctly, I will try and find an alternative, but for now, multiline comments may well be slightly broken as you have found.
You could try installing ripgrep version 12 manually and pointing the extension at the executable as a workaround.
Let's concentrate on single-line comments with repeated lines.
I have installed ripgrep version 12.1.1
Given the example above, and the following configuration:
{
"todo-tree.regex.regex": "[ \\t]*(/{2}+|#|;|')[ \\t]*($TAGS).*\\r?\\n(?:[ \\t]*\\1[ \\t]*.*\\r?\\n)*",
"todo-tree.ripgrep.ripgrep": "/usr/bin/rg",
"todo-tree.ripgrep.ripgrepArgs": "--max-columns=1000 --no-config --multiline --pcre2",
"todo-tree.regex.enableMultiLine": true,
"todo-tree.general.debug": true,
"todo-tree.general.tags": [
"BUG",
"HACK",
"FIXME",
"TODO",
"WARN"
],
}
I get nothing in the tree:
This is the output of the todo-tree:
13:53:20.126 Searching /home/pawel/todo-tags-exploration...
13:53:20.126 Writing pattern file:/home/pawel/.vscode-server/data/User/workspaceStorage/8eb22b1336743e8960987c83bee3510a/Gruntfuggly.todo-tree/rx8l3637n.txt
13:53:20.127 Pattern:[ \t]*(/{2}+|#|;|')[ \t]*(WARN|TODO|HACK|FIXME|BUG).*\r?\n(?:[ \t]*\1[ \t]*.*\r?\n)*
13:53:20.127 Command: /usr/bin/rg --no-messages --vimgrep -H --column --line-number --color never --max-columns=1000 --no-config --multiline --pcre2 -i -U -f "/home/pawel/.vscode-server/data/User/workspaceStorage/8eb22b1336743e8960987c83bee3510a/Gruntfuggly.todo-tree/rx8l3637n.txt" -g "!**/vendor/**" -g "!**/node_modules/**" -g "!**/dist/**" -g "!**/bower_components/**" -g "!**/build/**" -g "!**/.vscode/**" -g "!**/.github/**" -g "!**/.git**" -g "!**/_output/**" -g "!**/*.min.*" -g "!**/*.map" "/home/pawel/todo-tags-exploration"
13:53:20.174 Search results:
/home/pawel/todo-tags-exploration/todos.txt:1:1:// TODO: this is a long todo
/home/pawel/todo-tags-exploration/todos.txt:2:1:// another line
/home/pawel/todo-tags-exploration/todos.txt:3:1:// and yet another line
/home/pawel/todo-tags-exploration/todos.txt:7:1:# TODO: C style comment
/home/pawel/todo-tags-exploration/todos.txt:8:1:# another line
/home/pawel/todo-tags-exploration/todos.txt:12:1:; TODO: This is a comment in the
/home/pawel/todo-tags-exploration/todos.txt:13:1:; basic
/home/pawel/todo-tags-exploration/todos.txt:17:1:' TODO: this is another type of
/home/pawel/todo-tags-exploration/todos.txt:18:1:' a comment
/home/pawel/todo-tags-exploration/todos.txt:41:1: // TODO: Needs to be at any depth
/home/pawel/todo-tags-exploration/todos.txt:42:1: // continuation
/home/pawel/todo-tags-exploration/todos.txt:57:1:// WARN: this is another
/home/pawel/todo-tags-exploration/todos.txt:58:1:// thing that should be captured
Comments get correctly found, but not parsed by todo-tree?
If I disable my custom regex i start getting results in the tree, bot obviously only the first lines